Q
Problem solve Get help with specific problems with your technologies, process and projects.

Change the order of conditions in the WHERE clause

In the below select query, can the order of the conditions in my WHERE clause change the time of execution?

Let's say I have a select query like this:

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.

This was last published in July 2007

Dig Deeper on Oracle and SQL

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close