aspose file tools
The moose likes Oracle/OAS and the fly likes joins Vs nested queries Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Oracle/OAS
Reply Bookmark "joins Vs nested queries" Watch "joins Vs nested queries" New topic
Author

joins Vs nested queries

Sudharsan Govindarajan
Ranch Hand

Joined: Jul 03, 2002
Posts: 319
Hi!
In case of performance which is the best, Joins or Nested Queries?
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
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

Joined: Jul 03, 2002
Posts: 319
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

Joined: Sep 28, 2001
Posts: 925
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
 
 
subject: joins Vs nested queries
 
Threads others viewed
JDBC Code Optimization Question
can anyone tell me how many joins are in SQL.AND how many are in Oracle.?
Query taking forever
Subquery help needed
Unexpected Token Problem
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture