SQL Language (MOSC)

MOSC Banner

Tuning SQL Tree walk as a subselect in a where clause.

edited Feb 3, 2015 8:15AM in SQL Language (MOSC) 2 commentsAnswered

I have a query with a subselect that is a tree walk.

If I view a simple subselect like select * from my_table where journaltime=(select max(journaltime) from mytable) its my understanding that the sub select is fired first and the  result used in the outer query to return the max row.

My query now has

select ......... from a,b,c,d LEFT OUTER JOIN oN (for all join conditions)

where col_id =8888888888888888 or col_id in ( select col_id from ..... connect by prior ...start with....etc

The optimizer merges these queries (as it should you say) but the result is that it creates a huge results set the uses the subquery as a filter to return 2 rows. This results in approx

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center