SQLite PRAGMA

PRAGMA cache_spill

The cache_spill pragma enables or disables the ability of the pager to spill dirty cache pages to the database file in the middle of a transaction.

PRAGMA cache_spill;
PRAGMA cache_spill=boolean;
PRAGMA schema.cache_spill=N;

On the sample database

What PRAGMA cache_spill returns on the sample database, in SQLite 3.54.1 as built for the browser by sql.js:

cache_spill
1841

What the SQLite documentation says

The cache_spill pragma enables or disables the ability of the pager to spill dirty cache pages to the database file in the middle of a transaction. Cache_spill is enabled by default and most applications should leave it that way as cache spilling is usually advantageous. However, a cache spill has the side-effect of acquiring an EXCLUSIVE lock on the database file. Hence, some applications that have large long-running transactions may want to disable cache spilling in order to prevent the application from acquiring an exclusive lock on the database until the moment that the transaction COMMITs.

The "PRAGMA cache_spill=N" form of this pragma sets a minimum cache size threshold required for spilling to occur. The number of pages in cache must exceed both the cache_spill threshold and the maximum cache size set by the PRAGMA cache_size statement in order for spilling to occur.

The "PRAGMA cache_spill=boolean" form of this pragma applies across all databases attached to the database connection. But the "PRAGMA cache_spill=N" form of this statement only applies to the "main" schema or whatever other schema is specified as part of the statement.

From sqlite.org's pragma documentation for SQLite 3.54.1, in the public domain.

← cache_size · case_sensitive_like →