• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

joins Vs nested queries

 
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
In case of performance which is the best, Joins or Nested Queries?
 
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See point #30,
http://www.dbasupport.com/oracle/ora9i/performance/tuning-4.shtml
If your question relates to a specific piece of SQL use explain plan to find out what is happening - there may be other reasons why your query is slow.
Simon
 
Sudharsan Govindarajan
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Simon!
Thanks for that link. Did u mean point #20? It tells "In general, join tables rather than specifying sub-queries for them". But specifies no reason for it. Any ideas?
 
SJ Adnams
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i guess it comes down to how quickly oracle can seek out the rows that you are asking for.
if you join 2 tables on 3 values then each predicate reduces the number of rows. If you do the same with sub-queries then oracle will get the resultsets from each subquery and then perform the join.
That said, I use subquerys a lot e.g.
select a from b where c in (1,2,3) and d in ('x','y');
I've never thought about if,
select a from b where (c = 1 or c = 2 or c = ) and (d = 'x' or d = 'y');
..was any quicker.
There are plenty of other optimization steps that are made in an app before getting down to the example above.
HTH Simon
reply
    Bookmark Topic Watch Topic
  • New Topic