// sqlite · memory

cache_size

Page cache size for this connection: positive numbers are pages, negative numbers are KiB.

기본값
-2000 (about 2MB)
Range
Any integer; negative = KiB, positive = pages
Restart needed
아니요
Default checked on
SQLite 3.5x

기능

-2000 means about 2MB regardless of page size. Each connection has its own cache unless shared-cache mode is used.

기본값

-2000 (about 2MB). -2000 (a stock SQLite 3.5x build). The sqlite3 shipped with macOS reports 2000, which is 2000 pages (8MB with 4KB pages).

Check the current value

PRAGMA cache_size;

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

Change it

PRAGMA cache_size = -65536;   -- 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

Raise it (to tens of MB) for large databases read repeatedly by a long-lived connection.

What can go wrong

Memory per connection; with many connections it adds up.

The closest setting on other engines

엔진설정기본값Restart
SQLite cache_size this page -2000 (about 2MB) 아니요
PostgreSQL shared_buffers 128MB 예
MySQL innodb_buffer_pool_size 128MB 아니요
SQL Server max server memory (MB) 2147483647 아니요
Oracle sga_target 0 아니요

Questions about cache_size

What is the default value of cache_size in SQLite?

-2000 (about 2MB). -2000 (a stock SQLite 3.5x build). The sqlite3 shipped with macOS reports 2000, which is 2000 pages (8MB with 4KB pages).

Does changing cache_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 cache_size?

Raise it (to tens of MB) for large databases read repeatedly by a long-lived connection.

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

// one client for every engine

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