Skip to content

Commit 1aec584

Browse files
committed
config: set synchronous to NORMAL for writes
- https://www.sqlite.org/wal.html#performance_considerations
1 parent 982f5f1 commit 1aec584

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

crates/sqlx-sqlite-conn-mgr/src/database.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ impl SqliteDatabase {
242242
.execute(&mut *conn)
243243
.await?;
244244

245+
// https://www.sqlite.org/wal.html#performance_considerations
246+
sqlx::query("PRAGMA synchronous = NORMAL")
247+
.execute(&mut *conn)
248+
.await?;
249+
245250
self.wal_initialized.store(true, Ordering::SeqCst);
246251
}
247252

@@ -563,6 +568,17 @@ mod tests {
563568
"Journal mode should be WAL after first acquire_writer"
564569
);
565570

571+
// Check sync setting
572+
let (sync,): (i32,) = sqlx::query_as("PRAGMA synchronous")
573+
.fetch_one(&mut *writer)
574+
.await
575+
.unwrap();
576+
577+
assert_eq!(
578+
sync, 1,
579+
"Sync mode should be NORMAL after first acquire_writer"
580+
);
581+
566582
drop(writer);
567583

568584
db.remove().await.unwrap();

0 commit comments

Comments
 (0)