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.
Related on SQLly
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.