The MariaDB subquery cache feature added in MariaDB 5.3 is not widely known. Let’s see what it is and how it works.
What is a subquery cache?
The MariaDB subquery cache optimizes the execution of correlated subqueries. Correlated subqueries refer to a value from the parent query. For example:
SELECT id FROM product WHERE price NOT IN (SELECT MAX(price) FROM product GROUP BY category);
MariaDB only uses this optimization if the parent query is a SELECT, not an UPDATE or a DELETE. The subquery results get cached only for the duration of the parent query.
MariaDB added the subquery cache in v5.3. It is controlled by …
[Read more]