Let's say I have a select query like this:
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
select * from t1, t2 where t1.a = t2.a and t1.b = t2.b and t1.c = t2.c and t1.d = t2.d
Can the order of the conditions in my WHERE clause change the time of execution? If t1.c and t2.c are indexed, would that speed things up if I do like this:
select * from t1, t2 where t1.c = t2.c and t1.a = t2.a and t1.b = t2.b and t1.d = t2.d
The answer is no. All database optimizers are smart enough to figure out which columns have indexes and to adjust the execution plan accordingly, no matter which sequence the conditions are presented in.
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read an example of an SQL case expression from our SQL expert Rudy Limeback.continue reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback.continue reading
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.