Subject | Re: Order of tables in FROM clause |
---|---|
Author | Rick Roen |
Post date | 2005-09-05T16:59:56Z |
Just a guess, but probably the result set from t1 and t2 is quite
large and the result set from t1 and t3 is quite small. Then when
you go on to join or left join with the final table you have either
more or less records to join.
Regards,
Rick
large and the result set from t1 and t3 is quite small. Then when
you go on to join or left join with the final table you have either
more or less records to join.
Regards,
Rick
> I noticed a huge difference of query speed when i switched table2and
> table3 joins in FROM clause from:cf.field2
>
> select t1.stuff, t2.stuff, t3.stuff
> from table1 t1
> join table2 t2 on t2.id = t1.field4
> left join table3 t3 on t3.field1 = cf.field1 and t3.field2 =
> where t1.field1 = :p1cf.field2
> and t1.field2 = :p2
> and t1.field3 = :p3
>
> to:
>
> select t1.stuff, t2.stuff, t3.stuff
> from table1 t1
> left join table3 t3 on t3.field1 = cf.field1 and t3.field2 =
> join table2 t2 on t2.id = t1.field4
> where t1.field1 = :p1
> and t1.field2 = :p2
> and t1.field3 = :p3