// sqlite 3.5x

SQLite configuration settings

PRAGMA statements. Most apply to the current connection only and reset when it closes, so apps set them on every open; journal_mode=WAL, page_size and auto_vacuum are stored in the database file.

Inspect what your server runs with

PRAGMA journal_mode;
PRAGMA synchronous;
SELECT * FROM pragma_compile_options WHERE compile_options LIKE 'DEFAULT_%';

메모리

Caches, per-query work memory and the ceiling on what the server takes from the OS.

설정기본값Restart기능
cache_size -2000 (about 2MB) 아니요 Page cache size for this connection: positive numbers are pages, negative numbers are KiB.

WAL, redo & durability

What a COMMIT waits for and how the change log is sized and written.

설정기본값Restart기능
journal_mode delete 아니요 How SQLite keeps transactions atomic: a rollback journal or a write-ahead log (WAL).
synchronous 2 (FULL) 아니요 How often SQLite waits for data to reach the disk (fsync).

Checkpoints & recovery

How often dirty pages are flushed and how long crash recovery may take.

설정기본값Restart기능
wal_autocheckpoint 1000 pages 아니요 WAL size, in pages, at which a commit triggers an automatic checkpoint; 0 or less disables it.
journal_size_limit -1 (no limit) 아니요 Bytes of WAL or journal file kept on disk after a checkpoint or commit; -1 keeps everything.

Disk I/O

Flush rates, I/O threads and how the engine talks to the file system.

설정기본값Restart기능
page_size 4096 아니요 Size of a database page in bytes.
mmap_size 0 (off) 아니요 Bytes of the database file to access through memory-mapped I/O; 0 disables it.

Vacuum, statistics & maintenance

Background cleanup and the statistics the planner relies on.

설정기본값Restart기능
auto_vacuum 0 (NONE) 아니요 Whether free pages are returned to the OS automatically (FULL), on request (INCREMENTAL) or never (NONE).
analysis_limit 0 (no limit) 아니요 Approximate rows ANALYZE examines per index; 0 means all rows.

Query planner

Cost model and plan-shape switches.

설정기본값Restart기능
automatic_index 1 (on) 아니요 Let the planner build a temporary index for a join when none exists.

Timeouts

Limits on statements, lock waits and idle sessions.

설정기본값Restart기능
busy_timeout 0 아니요 Milliseconds to keep retrying when the database is locked by another connection, instead of failing with SQLITE_BUSY.

Temporary storage

Internal temporary tables, tempdb and spill space.

설정기본값Restart기능
temp_store 0 (DEFAULT, which means file) 아니요 Where temporary tables and indexes go: compile-time default, file or memory.

SQL behavior

Settings that change query results or locking semantics, not just speed.

설정기본값Restart기능
foreign_keys 0 (off) 아니요 Enforce FOREIGN KEY constraints.
defer_foreign_keys 0 (off) 아니요 Postpone foreign key checks to COMMIT for the current transaction.
locking_mode NORMAL 아니요 Whether the connection releases file locks after each transaction (NORMAL) or keeps them (EXCLUSIVE).
recursive_triggers 0 (off) 아니요 Allow triggers to fire other triggers recursively, including themselves.

Security & access

Network exposure and features that widen the attack surface.

설정기본값Restart기능
secure_delete 0 (off) 아니요 Overwrite deleted content with zeros.
trusted_schema 1 (on) 아니요 Whether SQL functions and virtual tables used in the schema (views, triggers, CHECK constraints) are trusted to run.

SQLite configuration FAQ

Why did my PRAGMA stop working?

Most pragmas, including foreign_keys, busy_timeout, cache_size and synchronous, last for one connection. A connection pool or a new process starts with the defaults again, so set them in the code that opens each connection.

Are SQLite defaults the same everywhere?

No. Defaults are compile-time options, and builds differ. The sqlite3 shipped with macOS, for example, reports cache_size 2000 (pages, not KiB), journal_size_limit 32768 and secure_delete FAST, while a stock build reports -2000, -1 and 0. The sqlite3 command-line shell also turns trusted_schema off for its own connections. PRAGMA compile_options shows what your build changed.

Which settings persist in the database file?

journal_mode=WAL (other journal modes do not persist), page_size and auto_vacuum (both need a VACUUM to change on an existing database), user_version and application_id. Everything else is per connection.

The full list is in the SQLite manual. Other engines: PostgreSQL, MySQL, SQL Server, Oracle.

// one client for every engine

Run these queries against your own server

SQLly connects to SQLite and the other engines in this reference from one desktop app on macOS, Windows and Linux, with a results grid you can sort, filter and export.