|
-
In CBO, the order of tables in the FROM clause and joins in the WHERE clause do not matter in 99.9% of the cases. However, for human readability, I follow this convention:
Bring one table at a time into the WHERE clause
Restrict it by every constant/variable available
Join it to every table available
This new table goes on the left of the operator, with the existing tables, constants and variables on the right
Start with the most restricted tables first and save the lookups for last.
Line up all the columns (operands operators operands AND/ORs)
Whatever order of tables I end up with in the WHERE clause, I mimick in the FROM clause.
Following these conventions will make the statements more readable, more maintainable, and possibly more efficient (because joining everything.restricting everything gives the optimizer more chances to get it right, and because that last .1% of the time where the order *does* make a difference, this standard will help)
- Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|