Subject | Re: [firebird-support] Theory about join vs where |
---|---|
Author | Tetram Corp |
Post date | 2009-06-15T11:38:57Z |
I was thinking about this kind of criteria:
select *
from
invoices inner join products on invoices.pk = products.fk
where
invoices.year = 2009
and products.quantity > 10;
In this case, putting test about year or quantity in join will not
produce a different result
But what about efficiency ?
Is it better to reduce records count in join or in where ? Because I
guess the less records there are, the fastest the join will be. But am I
right ? Is the where used after or before the where ? etc
Thierry
Dimitry Sibiryakov a écrit :
select *
from
invoices inner join products on invoices.pk = products.fk
where
invoices.year = 2009
and products.quantity > 10;
In this case, putting test about year or quantity in join will not
produce a different result
But what about efficiency ?
Is it better to reduce records count in join or in where ? Because I
guess the less records there are, the fastest the join will be. But am I
right ? Is the where used after or before the where ? etc
Thierry
Dimitry Sibiryakov a écrit :
>> Are there rules about join and where ?
>>
>
> The rules are simple: join criteria are put into join, filter
> criteria are put into where. Generally, same conditions in join and in
> where used to produce different results.
>
> SY, SD.
>
>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Yahoo! Groups Links
>
>
>
>