SQL Performance (MOSC)

MOSC Banner

Slow execution of query with 2 conditions

edited Jul 9, 2015 11:21AM in SQL Performance (MOSC) 4 commentsAnswered
 Query plan for query
select * from Persons p where  (p.Id = 68057) or
(p.Id in (select FromId from links where ToId = 68057))

has "TABLE ACCESS FULL" operation and query execution is much slower than execution of queries with one of
condition:
select * from Persons p where (p.Id = 68057),
select * from Persons p where (p.Id in (select FromId from links where ToId = 68057)) .

I tested this problem on 10.2.0.4 version for Linux 64-bit and on 11.2.0.1 for Windows 32-bit.
The only way to improve execution time that I know is to use "union" instead of "or".
Can any existing version of Oracle Database execute this query quickly?

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