By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,321 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,321 IT Pros & Developers. It's quick & easy.

Cost based optomizer problem. CBO won't merge view

P: n/a
I'm having a serious problem with the cost based optimizer in Oracle
8i.

I've created a view off of a couple of tables using a "union all".
i.e.
create view a_anti_a_view
select a.id1, b.name from a, b where a.id1 = b.id
union all
select a.id2, b.name2 from a, b where a.id2 = b.id
Table 'a' has 100K rows but 'b' has < 300.

when I run the following query I get a 50msec response:
select *
from a_anti_a_view av
where av.asset_id = 822775;

however this one takes around 2 minutes.
select *
from a_anti_a_view av
where av.asset_id in (select id from temp_as);

Even though temp_as has only one row!
Looking at the explain plan it's clear the optomizer isn't merging
the sub select into the view! It therefore does full table scans on
the selects within the view and then hash-joins to the temp_as table.

Has anyone had this problem? Does anybody have any suggestions?

I've tried a number of things, including using hints (although I'm
not very familiar with them), analyzing the tables and indexes and
doing a join instead of an 'in' operation. none help.

Any help would be fantastic. This is a large project and I'm pretty
far under the gun.
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> select *
from a_anti_a_view av
where av.asset_id in (select id from temp_as);


You might try re-writing query as standard join and force a nested loop join:
select /*+ use_nl */
col_list
from
a_anti_a_view av,
temp_as t
where
av.asset_id =t.temp_as;
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.