Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Optimizing SQL to Reduce Table Scans
I am using 2 tables: an Order Header and Order Detail. The problem that
I keep running into is for a request to pull some criteria based on the
detail lines, then display all the lines for orders meeting that
criteria.
So I believe that the SQL is first executing to get all the line(s) that meet the criteria. Then it is going back through the table to gather the header and all detail lines that meet the previous criteria. This results in multiple table scans.
Is this the correct way to do this? Is there a more efficient way?
Below is an example of this SQL:
SELECT DISTINCT
OH.ORDER_NUMBER, OH.ORDER_DATE, OD.LINE_NUMBER, OD.ORDER_CODE, OD.ORDER_STATUS