S
Supanote
Sign in Sign up

High-Performance SQLite Production PRAGMAs

plain (sql) 22 hours ago · 24 lines · 7 views
1-- High-Performance Concurrent SQLite Configuration
2-- Run immediately after opening database connection
3
4-- 1. Enable Write-Ahead Logging (concurrent readers + writer)
5PRAGMA journal_mode = WAL;
6
7-- 2. Synchronous NORMAL is safe in WAL mode and drastically cuts fsync calls
8PRAGMA synchronous = NORMAL;
9
10-- 3. In-memory temporary tables and indices
11PRAGMA temp_store = MEMORY;
13-- 4. Set 64MB page cache (-64000 KB)
14PRAGMA cache_size = -64000;
16-- 5. Busy timeout to prevent immediate locked database failures (5 seconds)
17PRAGMA busy_timeout = 5000;
19-- 6. Enforce Foreign Key relational constraints
20PRAGMA foreign_keys = ON;
22-- 7. Memory-mapped I/O (up to 256MB)
23PRAGMA mmap_size = 268435456;

No replies yet

Every reply is a note. Start a discussion, ask a question, or attach a code snippet.

Share Note

Download SVG
Social Card Preview
Open on mobile
Point your phone camera to open this note directly

Report this note

Notification