// sqlite · disk i/o

mmap_size

Bytes of the database file to access through memory-mapped I/O; 0 disables it.

Predeterminado
0 (off)
Range
0 up to SQLITE_MAX_MMAP_SIZE
Restart needed
No
Default checked on
SQLite 3.5x

Lo que hace

Reads through the mapping skip a copy into the page cache. The value is capped by the compile-time SQLITE_MAX_MMAP_SIZE (the macOS system build reports 1GB).

Valor predeterminado

0 (off). 0 (a stock SQLite 3.5x build).

Check the current value

PRAGMA mmap_size;

Change it

PRAGMA mmap_size = 268435456;   -- 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

Read-heavy applications on 64-bit systems where the database is up to a few hundred MB.

What can go wrong

An I/O error on a mapped page crashes the process (SIGBUS) instead of returning an error; some platforms handle mapped writes poorly.

Questions about mmap_size

What is the default value of mmap_size in SQLite?

0 (off). 0 (a stock SQLite 3.5x build).

Does changing mmap_size 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 mmap_size?

Read-heavy applications on 64-bit systems where the database is up to a few hundred MB.

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

// one client for every engine

Check mmap_size 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.