Hi, Investigating this further, a potential fix is for the temp DBs to follow the main DB's MMap setting like so: ``` i64 max = db->szMmap; ``` Similar to how the cache size for temp DBs follows the main DB's cache size in `sqlite3VdbeSorterInit`: ``` mxCache = db->aDb[0].pSchema->cache_size; ``` This limits the total temp DB memory usage to a multiple of the setting for the main DB, as the settings apply to _every_ temp DB and we may need multiple ones for a query.