1) The (default) 4 table limit on
where clauses:
If there are more than 4 tables
in a join criterion then the optimizer does not calculate all possible
query plans as there will be too many. What it does is find all plans for
first 4 tables. Then find all plans for next 4 tables (alone) etc until all
tables are covered. It then selects the most optimal plan. This can lead to
apparently strange behaviour e.g.
Select table1.* from table1,
..2, ..3, ..4, ..5
where table1.x = table2.x
and table1.x = table3.x
and table1.x = table4.x
and table1.x = table5.x
The query plans that include the
table 1 to 4 where clauses will be calculated together. However the final
where clause with table5 will be calculated in isolation. In this situation
it would be important to ensure that the most important tables (i.e. the
ones with the most data) are present in the table 1-4 group. Likewise,
grouping related tables is advisable.
|