I know SQLite has logic where it can create [Automatic Indexes](https://www.sqlite.org/optoverview.html#automatic_indexes) to help with queries. Perhaps if that was combined with [AS MATERIALIZED](https://www.sqlite.org/lang_with.html#materialization_hints) hints to let it know it's ok to consider making an index on the materialization of the with statement? Or is that already the case?