I have 2 tables, Make and Model where Make is the master table and Model has
a reference of make table by Make_Id since there can be multiple models for a
single make. Now, i have 4 SQL's below and i want to know which SQL should
perform better.
select make.make_name, model.model_name
from make, model
where make.make_id = 1000
and make.make_id = model.make_id
select make.make_name, model.model_name
from make, model
where make.make_id = 1000
and model.make_id = make.make_id
select make.make_name, model.model_name
from make, model
where make.make_id = model.make_id
and make.make_id = 1000
select make.make_name, model.model_name
from make, model
where model.make_id = make.make_id
and make.make_id = 1000
Thanks,
Moin
On Wed, 20 Apr 2005 12:14:02 -0700, MoinJ wrote:
>I have 2 tables, Make and Model where Make is the master table and Model has
>a reference of make table by Make_Id since there can be multiple models for a
>single make. Now, i have 4 SQL's below and i want to know which SQL should
>perform better.
>select make.make_name, model.model_name
>from make, model
>where make.make_id = 1000
>and make.make_id = model.make_id
>
>select make.make_name, model.model_name
>from make, model
>where make.make_id = 1000
>and model.make_id = make.make_id
>
>select make.make_name, model.model_name
>from make, model
>where make.make_id = model.make_id
>and make.make_id = 1000
>
>select make.make_name, model.model_name
>from make, model
>where model.make_id = make.make_id
>and make.make_id = 1000
>Thanks,
>Moin
Hi Moin,
The usual answer to "which of these queries performas better" is to test
them all, in _your_ database, on _your_ tables with _your_ data and on
_your_ hardware. However, in this case it's safe to say that you won't
see any difference. The query optimizer is free to reshuffle the
expressions in the where clause (as long as it won't effect the end
result), so you can expect all four queries to result in the exact same
execution plan.
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment