Supporting all kinds of outer references in derived tables (lateral, or not)

Hi. In my earlier post, I showed how MySQL, since version 8.0.14, has support for LATERAL derived tables. With LATERAL, a JOIN can have a second table – a subquery-based derived table – be defined based on values from columns of the first table, and thus be re-calculated for each row of the first table. Typically:

SELECT ... FROM t1, LATERAL (SELECT ... FROM t2
                ^            WHERE t2.col=t1.col ... ) AS derived;
                |                           |
                |                           |
                +---------------------------+

We say that in the second table (derived), t1.col is a “lateral outer reference” to the first table t1. The word “lateral” hints at the fact that the referenced table is placed “next to”, “on the side of” the derived table (i.e. both are part of the same FROM clause). The arrow goes “laterally”.
While implementing this LATERAL feature, I added another related one at the same time: support for NON-lateral outer references in derived tables. Please, find all information in my post on mysqlserverteam.


Commentaires

Posts les plus consultés de ce blog

WITH RECURSIVE and MySQL

Faster subqueries with materialization