conditions in where; the order

A

alekm

Hi,
I'd like to know which condition in where part of sql will be considered
first. I'd like to optimize sqls.
For example: select * from table t where condition1 and condition2 and
condition3

thank you in advance

alekmil
 
B

BruceM via AccessMonster.com

Unless I'm missing something in your question it doesn't matter. I suppose
the first one will be "considered" first, but a search of the parking lot for
all Fords that are black will return the same list as the number of black
vehicles that are Fords. It may be best to index the fields that are used
for sorting, filtering, and so forth, but other than that I'm not sure what
you mean by "optimize".
 
A

alekm

The result will be the same in the end but time spent will not be same I
guess. I tought of making sql faster when I said optimize.
 
B

BruceM via AccessMonster.com

Why do you guess the time will not be the same?
The result will be the same in the end but time spent will not be same I
guess. I tought of making sql faster when I said optimize.
Unless I'm missing something in your question it doesn't matter. I suppose
the first one will be "considered" first, but a search of the parking lot for
[quoted text clipped - 12 lines]
 
J

Jerry Whittle

Hi Bruce,

In older versions of Oracle, the order could matter. Basically the last part
of the Where statement was evaluated first. However never versions of Oracle
use query optimization to run queries how Oracle thinks best. Access does the
same thing. Basically the first time you run a query, it might be slower as
Access is figuring out how to run it faster in the future. That's why any
time you are putting a stopwatch against a form, report, or query, you should
run it twice after messing with the SQL. The second and subsequent times will
probably be faster.

This was cross-posted to another forum and I suggested that alekm use the
Jet Showplan to check how a query actually runs.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


BruceM via AccessMonster.com said:
Why do you guess the time will not be the same?
The result will be the same in the end but time spent will not be same I
guess. I tought of making sql faster when I said optimize.
Unless I'm missing something in your question it doesn't matter. I suppose
the first one will be "considered" first, but a search of the parking lot for
[quoted text clipped - 12 lines]

--



.
 
B

BruceM via AccessMonster.com

Thanks for the information. I looked at the link. From what I can gather
Access "remembers" the plan from one session to another unless there is a
compact and repair or a saved change to the query.

Jerry said:
Hi Bruce,

In older versions of Oracle, the order could matter. Basically the last part
of the Where statement was evaluated first. However never versions of Oracle
use query optimization to run queries how Oracle thinks best. Access does the
same thing. Basically the first time you run a query, it might be slower as
Access is figuring out how to run it faster in the future. That's why any
time you are putting a stopwatch against a form, report, or query, you should
run it twice after messing with the SQL. The second and subsequent times will
probably be faster.

This was cross-posted to another forum and I suggested that alekm use the
Jet Showplan to check how a query actually runs.
Why do you guess the time will not be the same?
[quoted text clipped - 6 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top