开发者

Oracle - JOIN two complex Views - optimizer faults

开发者 https://www.devze.com 2023-03-27 23:38 出处:网络
I have two 开发者_运维问答pretty complex views. I need to produce report that will join both by some column.

I have two 开发者_运维问答pretty complex views. I need to produce report that will join both by some column. Each of views separately returns in less than a minute with complete result set. When I join them optimizer rebuilds query and makes weird things so result doesn't return at all. The question is whether there is a way to tell the optimizer to retrieve both sets first and only then join them (each set is only some thousands of records).

For time being the solution is based on creating intermediate table (materialized view also worked), but I'd like to do that in single query,

Thank you


Without being able to see the explain plan, query, views, and table structure is hard to say for sure. I will say that often in these cases the best answer is to rewrite the query to not use the views and just do what you want directly. That'll probably solve it.

If you can't do that, try the NO_REWRITE optimizer hint. Like this:

SELECT /*+ NO_REWRITE */ rest_of_your_query_goes_here

That will tell Oracle to try and interpret your query directly and not try to rewrite it.

0

精彩评论

暂无评论...
验证码 换一张
取 消