3.3 Joins and subqueries | |
Joins are done via nested-join. There are some heuristics in Texis to reorder the tables in the join. If these are disabled (set nooptimize='join') then the tables are looked at in the order specified. The heuristics used by Texis are to put any tables with no usable indices first, then any table that has a constant expression that can be evaluated with an index, then it looks for tables that have conditions based on previously used tables. This is repeated until all tables are used.
The idea behind doing tables with no indexes first is that you only want to scan them once, not repetitively. Then you want to try and get the smallest set of records at each point, so the work done will be kept to a minimum. As a developer you may know more about typical queries and data distributions, which may allow you to pick a better table ordering.
Back: Ordering clauses | Next: Choosing the appropriate indices |