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!

Order Of Operations in Where Clause?

User_ZR3PENov 21 2022

I searched a web for order of operations in where clause but I encountered articles about order of operations in sql in general. I wonder order of operations in WHERE clause beacuse I have a very big two tables (around 2,1 billion rows for each table). I want to make them filter for DATE field after then filter them on common field. If my SQL query first try to filter each other on common field then filter for DATE field it would take unnecessary amount of time to complete to query. How can I prioritize DATE filtering over common field filtering?
SELECT *
FROM
TABLE1,
TABLE2
WHERE TABLE1.DATE >= TO_DATE('18.11.2022','DD.MM.YYYY')
AND TABLE1.DATE < TO_DATE ('18.11.2022','DD.MM.YYYY') + 1
AND TABLE2.DATE >= TO_DATE('18.11.2022','DD.MM.YYYY')
AND TABLE2.DATE < TO_DATE ('18.11.2022','DD.MM.YYYY') + 1
AND TABLE1.TRANSACTIONID=TABLE2.TRANSACTIONID ;

This post has been answered by mathguy on Nov 21 2022
Jump to Answer
Comments
Post Details
Added on Nov 21 2022
4 comments
837 views