SQLite Forum

CREATE INDEX ignoring pragma cache_size - is there a way to fix?
Login
How are you measuring memory usage?

With temp_store=FILE, a CREATE INDEX statement for a large index should use approximately 2x (or (n+2)x if you have SQLite configured to use n background threads when sorting) the configured cache-size in heap memory. It also uses temporary files, usually in /tmp, but sometimes in some other place:

[](https://sqlite.org/tempfiles.html#temporary_file_storage_locations)

Depending on how you're measuring memory usage and where they are being created, the temp files may be being included in the measurement.

Dan.