Skip to content

Commit 8d00fd8

Browse files
hitalinclaude
andcommitted
perf: SQLite PRAGMA チューニングでread性能を改善
WALモードのデスクトップアプリ向けに攻めた設定を追加: - synchronous=NORMAL: WALでは安全性を損なわずfsync削減 - mmap_size=256MB: readをsyscallからメモリアクセスに - cache_size=16MB: ページキャッシュをデフォルト2MBから拡大 - temp_store=MEMORY: 一時テーブル・ソートをメモリ上で実行 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c3beeb7 commit 8d00fd8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/db.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ pub struct Database {
3535
impl Database {
3636
pub fn open(path: &Path) -> Result<Self, NoteDeckError> {
3737
let mut conn = Connection::open(path)?;
38-
conn.execute_batch("PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON;")?;
38+
conn.execute_batch(
39+
"PRAGMA journal_mode=WAL;\
40+
PRAGMA foreign_keys=ON;\
41+
PRAGMA synchronous=NORMAL;\
42+
PRAGMA mmap_size=268435456;\
43+
PRAGMA cache_size=-16000;\
44+
PRAGMA temp_store=MEMORY;",
45+
)?;
3946

4047
// Run numbered migrations (V1, V2, ...)
4148
embedded::migrations::runner().run(&mut conn).map_err(|e| {

0 commit comments

Comments
 (0)