Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> SQL Where clause order of operations?
I have an SQL insert statement that is designed to find Sales records that do
not have a corresponding Quota record. From that result set the statement is
to insert a corresponding 'dummy' Quota record for any orphaned Sales
records.
The question concerns the way in which Oracle 7.3 interprets the Where clause. My understanding is that all table joins will be completed and then any non-table joins criteria will 'filter' out the appropriate records.
This statement accomplishes that successfully.
INSERT INTO INC_QUOTA
SELECT S.SALES_YEAR, S.SALES_WEEK, S.TERRITORY_CODE,
S.BRAND_CODE, 0.0
FROM inc_sales_summary s, inc_quota q
WHERE s.sales_week = q.sales_week (+) and s.sales_year = q.sales_year (+) and s.territory_code = q.territory_code (+) and s.brand_code = q.brand_code (+) and s.sales_week <= ai_weekboundary and q.sales_week IS NULL;
However, there is a debate going among my colleagues that the final two lines 's.sales_week <= ai_weekboundary' and 'q.sales_week IS NULL' should be interpretted before any of the table joins as it could potentially make the table joins smaller and faster be removing undesired records.
I've heard this argument before but have not been able to verify if either one of these scenarios is the correct scenario.
Question: How does Oracle interpret the Where clause criteria? Are table joins completed first or are non-table joins completed first?
Any insight into this would be greatly appreciated! Daniel
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Fri Jul 10 1998 - 15:41:03 CDT
![]() |
![]() |