About

SQL is a declarative language and does not specify the actual algorithm used to resolve a query. The query plan generator can generate a number of semantically equivalent approaches to resolving a query and select the one that it estimates to be most efficient based on a heuristic.

Various transformations can be applied to a query plan for example, the order in which tables are joined or predicates applied can be changed, various join algorithms such as hash, merge or nested loops joins can be used, or internal results can be calculated and materialised for later use.

A sub-optimal plan can result in poor query performance. Most database management systems supply tools for analysing query plans and examining the query plan is a key technique for tuning a query.

history | show excerpt | excerpt history