How to disable subquery flattening in sqlite How to disable subquery flattening in sqlite sqlite sqlite

How to disable subquery flattening in sqlite


Just break one of the rules listed in the documentation.

The easiest would be to add an OFFSET clause that has no effect:

SELECT ...FROM (SELECT ...      FROM ...      LIMIT -1 OFFSET 0)WHERE ...

If you really want to change the source code: just return from the flattenSubquery function in select.c without doing anything.It already has the following line at the beginning:

if( OptimizationDisabled(db, SQLITE_QueryFlattener) ) return 0;