Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 34.6Mb
PDF (A4) - 34.6Mb
PDF (RPM) - 32.3Mb
HTML Download (TGZ) - 8.2Mb
HTML Download (Zip) - 8.2Mb
HTML Download (RPM) - 7.0Mb
Man Pages (TGZ) - 147.5Kb
Man Pages (Zip) - 208.8Kb
Info (Gzip) - 3.1Mb
Info (Zip) - 3.2Mb


MySQL 8.0 Reference Manual  /  ...  /  Optimizing Subqueries, Derived Tables, View References, and Common Table Expressions

Pre-General Availability Draft: 2017-12-16

8.2.2 Optimizing Subqueries, Derived Tables, View References, and Common Table Expressions

The MySQL query optimizer has different strategies available to evaluate subqueries. For IN (or =ANY) subqueries, the optimizer has these choices:

  • Semi-join

  • Materialization

  • EXISTS strategy

For NOT IN (or <>ALL) subqueries, the optimizer has these choices:

  • Materialization

  • EXISTS strategy

For derived tables (subqueries in the FROM clause), the optimizer has these choices:

  • Merge the derived table into the outer query block

  • Materialize the derived table to an internal temporary table

For view references and common table expressions, the optimizer has the same choices as for derived tables.

The following discussion provides more information about the preceding optimization strategies.

Note

A limitation on UPDATE and DELETE statements that use a subquery to modify a single table is that the optimizer does not use semi-join or materialization subquery optimizations. As a workaround, try rewriting them as multiple-table UPDATE and DELETE statements that use a join rather than a subquery.


User Comments
Sign Up Login You must be logged in to post a comment.