Home » SQL & PL/SQL » SQL & PL/SQL » which is execute first
which is execute first [message #228215] Mon, 02 April 2007 02:05 Go to next message
muzahid
Messages: 281
Registered: September 2004
Location: Dhaka, Bangladesh
Senior Member
i have 2 query
select col1,col2 from table1 where col1='11' or col1='22' or col1='33'

and another one

select col1,col2 from table1 where col1 in ('11','22','33')

Which one query execute fast
Re: which is execute first [message #228216 is a reply to message #228215] Mon, 02 April 2007 02:15 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
What happens if you try it?
Surely you will not trust us on our word? If I would say 'the first one is faster' would you blindly follow me??
Re: which is execute first [message #228221 is a reply to message #228215] Mon, 02 April 2007 02:23 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
They will be the same. Internally, Oracle recognises that each of the OR predicates is an equals clause on the same column, which it converts to an IN list.

If for some reason Oracle did NOT recognise that the OR list was semantically equivalent to an IN list, then the IN-list would be marginally quicker because it performs a single index-scan and the ORs would be forced to perform separate index scans.

Ross Leishman
Re: which is execute first [message #228287 is a reply to message #228215] Mon, 02 April 2007 07:45 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Fast or first?
Re: which is execute first [message #228364 is a reply to message #228216] Mon, 02 April 2007 12:53 Go to previous message
Ericle
Messages: 44
Registered: April 2006
Location: United States of America ...
Member

Frank wrote on Mon, 02 April 2007 03:15
What happens if you try it?
Surely you will not trust us on our word? If I would say 'the first one is faster' would you blindly follow me??


I would. Laughing
Previous Topic: Help Required in Procedure
Next Topic: Query Help
Goto Forum:
  


Current Time: Sun Dec 04 04:34:15 CST 2016

Total time taken to generate the page: 0.18981 seconds