// sqlite · memory

cache_spill

Let the pager write dirty cache pages to the database file in the middle of a transaction.

Standard
1 (on)
Range
ON, OFF, or a page-count threshold
Restart needed
Nein
Default checked on
SQLite 3.5x

Was es bewirkt

On by default. Spilling keeps long transactions from holding every dirty page in memory, but a spill takes an EXCLUSIVE lock on the database file that lasts until COMMIT. The boolean form covers every attached database; cache_spill=N raises the threshold for main (or a named schema) alone, and pages then have to pass both that threshold and cache_size before spilling starts.

Standardwert

1 (on). On (a stock SQLite 3.5x build).

Check the current value

PRAGMA cache_spill;

SELECT * FROM pragma_cache_spill;   -- table-valued form, usable in queries

Change it

PRAGMA cache_spill = OFF;   -- this connection only

No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When to change it

Leave it on unless a very large, long-running transaction should not take the file's EXCLUSIVE lock early, so other writers are not locked out until COMMIT.

What can go wrong

With spilling off, dirty pages pile up in memory, so a transaction writing more pages than the cache holds has nowhere to put them until COMMIT; memory use jumps and the commit itself does more work at once.

Questions about cache_spill

What is the default value of cache_spill in SQLite?

1 (on). On (a stock SQLite 3.5x build).

Does changing cache_spill require a restart?

No. No restart. It applies at once to the connection that runs it and is lost when that connection closes, so set it every time a connection opens.

When should I change cache_spill?

Leave it on unless a very large, long-running transaction should not take the file's EXCLUSIVE lock early, so other writers are not locked out until COMMIT.

Back to all SQLite settings, or check the SQLite manual for every option.

// one client for every engine

Check cache_spill on your own server

SQLly runs the query above against SQLite and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

Text und Daten auf dieser Seite: CC BY 4.0, Quelle: SQLly (sqlly.app). Code und SQL-Snippets: MIT. Lizenzdetails