Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Optimizing Query, Filter than Join or Join than Filter

liangtehNov 22 2008 — edited Nov 28 2008
Hi Everyone,

I am looking at the placement of my where condition to optimize the stored procedures. I have 2 tables A, B, C. A has 10million records B has 1000 record and C has about 10 records I am doing a join on A, B and C.

A.D is a varchar. Please advise which approach should I take to optimize my query. Thank you!

Method 1. Filter the result set first than perform a join
SELECT *
FROM
(
SELECT * FROM
A WHERE DATE BETWEEN X AND Y
AND A.D = PARAMETER
)
WHERE A.B = B.B
AND A.C = C.C

Method 2. Perform a join than filter the parameter
SELECT *
FROM
(
SELECT * FROM
A WHERE DATE BETWEEN X AND Y
)
WHERE A.B = B.B
AND A.C = C.C
AND A.D = PARAMETER

Edited by: liangtehz on Nov 22, 2008 4:18 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 26 2008
Added on Nov 22 2008
10 comments
966 views