Previous Topic

Next Topic

Improved Query Performance with Optimized Join Orders

A slow query was reported where the join strategy picked was not the best one based on inspection of the execution plan. The join order optimization logic has been adjusted so that it recognizes table pairs t1, t2 such that:

  1. t1 has no index on the join column;
  2. t2 has a unique index on the join column;
  3. t2 does not have any other join condition with any other table;
  4. The join condition between t1 and t2 is on a single field.

After this the remaining tables, excluding table t2, are ordered. After the join order is obtained t1 is replaced with [t1 join t2] , t2 being to the right of t1. Note that the cardinality of [t1 join t2] will be the same as that of t1, as t2 has an unique index on the join column.