perf(db): enable SQLite WAL mode and performance settings
All checks were successful
Build MIPS Binary / build (push) Successful in 4m14s
All checks were successful
Build MIPS Binary / build (push) Successful in 4m14s
- PRAGMA journal_mode=WAL - concurrent reads while writing - PRAGMA synchronous=NORMAL - faster than FULL, still safe - PRAGMA busy_timeout=5000 - reduces database locked errors Note: Existing databases should be deleted to enable WAL mode properly.
This commit is contained in:
@@ -21,6 +21,21 @@ impl Db {
|
||||
}
|
||||
|
||||
async fn run_migrations(&self) -> Result<()> {
|
||||
// WAL mode - enables concurrent reads while writing
|
||||
sqlx::query("PRAGMA journal_mode=WAL")
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
|
||||
// NORMAL synchronous - faster than FULL, still safe enough
|
||||
sqlx::query("PRAGMA synchronous=NORMAL")
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
|
||||
// 5 second busy timeout - reduces "database locked" errors
|
||||
sqlx::query("PRAGMA busy_timeout=5000")
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
|
||||
sqlx::migrate!("./migrations").run(&self.pool).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user