From eef51f064a32eb3e35b9b07116d1227101ba2093 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 25 Apr 2021 23:12:37 +0300 Subject: [PATCH] sql: set PRAGMA synchronous=normal It was set in `sqlx` code, but not in `rusqlite` mode. synchronous=FULL makes benchmark that write to the database a lot slower. --- src/sql.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sql.rs b/src/sql.rs index 1ff9938b3..f2c478201 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -124,9 +124,12 @@ impl Sql { *self.pool.write().await = Some(Self::new_pool(dbfile.as_ref(), readonly)?); if !readonly { - // journal_mode is persisted, it is sufficient to change it only for one handle. self.with_conn(move |conn| { + // journal_mode is persisted, it is sufficient to change it only for one handle. conn.pragma_update(None, "journal_mode", &"WAL".to_string())?; + + // Default synchronous=FULL is much slower. NORMAL is sufficient for WAL mode. + conn.pragma_update(None, "synchronous", &"NORMAL".to_string())?; Ok(()) }) .await?;