[英]Oracle Query upon a Pipelined function works ok but chokes if I add a condition
I have a pipelind functions that returns a collection of custom objects, ie a nested table. 我有一个pipelind函数,它返回一组自定义对象,即一个嵌套表。
It works great ( < 4 seconds) when I select from it like this; 当我从中选择它时,它工作得很好 (<4秒);
select e.* from table(MY_PIPLINED_FUNCTION)e
But when I add any condition (apart from where rownum<X
), the query takes forever to execute (like 5+ minutes) but it does return the desired value correctly at the end . 但是当我添加任何条件时(除了
where rownum<X
),查询需要永远执行(如5分钟以上),但它确实在最后正确返回所需的值 。
What's boggling me is that it is working but it takes an enormous amount of time to complete. 令我难以置信的是它正在发挥作用,但需要花费大量时间才能完成。
Has anyone got any ideas on this? 有没有人对此有任何想法?
ps: it's a large result set, both in number of rows (30K+) and in number of columns (50+columns). ps:它是一个大的结果集,包括行数(30K +)和列数(50 +列)。
Are you comparing the time to get the entire result set? 您是否在比较获得整个结果集的时间? Or just the first N rows?
或者只是前N行?
Does your predicate filter out 99% of the data, making one query work much harder to get those N rows? 你的谓词是否过滤了99%的数据,使得一个查询更难以获得这N行?
The pipelined function may not have anything to do with it. 流水线功能可能与它没有任何关系。 You can have a pipelined function and still retrieve the first N rows without evaluating the entire result set.
您可以使用流水线函数并仍然检索前N行而不评估整个结果集。 For example, the infinite loop below will quickly return results in an IDE that only retrieves a small number of rows.
例如,下面的无限循环将在IDE中快速返回结果,该IDE仅检索少量行。
create or replace type number_nt as table of number;
create or replace function pipe_function return number_nt pipelined is
begin
while 1 = 1 loop
pipe row(1);
end loop;
end;
/
select column_value
from table(pipe_function)
where column_value < 2;
You may need to add more details about your function and predicate. 您可能需要添加有关函数和谓词的更多详细信息。
It gets the entire result set in order to apply filters. 它获取整个结果集以应用过滤器。
You should improve the MY_PIPLINED_FUNCTION. 你应该改进MY_PIPLINED_FUNCTION。 Probably now it uses indexes and because of this the first_rows comes fast.
可能现在它使用索引,因此first_rows速度很快。
1.You can try to force it to use hash for joins.(this may get the full resultset in less time, but first rows will not come rapidly) 1.您可以尝试强制它使用哈希进行连接。(这可能会在更短的时间内获得完整的结果集,但第一行不会很快出现)
2.You can modify the function, and put the contiditions in the arguments of the function, modifying the function consequently - filter the rows from specific table. 2.您可以修改函数,并将函数放在函数的参数中,然后修改函数 - 从特定表中过滤行。 (IE instead of
(IE而不是
select e.* from table(MY_PIPLINED_FUNCTION)e
where e.name = 'mark'
to do 去做
select e.* from table(MY_PIPLINED_FUNCTION('mark'))e
) )
These things may help... 这些东西可能有帮助......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.