Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/core/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ pub struct DatabaseStats {
impl Database {
pub fn new(path: &Path) -> Result<Self> {
let conn = Connection::open(path)?;

// Enable WAL mode for better concurrency and write performance
conn.pragma_update(None, "journal_mode", "WAL")?;

// Set a busy timeout to handle lock contention gracefully (5 seconds)
conn.busy_timeout(std::time::Duration::from_secs(5))?;

// Set synchronous mode to NORMAL for better performance while maintaining safety in WAL mode
conn.pragma_update(None, "synchronous", "NORMAL")?;

let db = Self { conn };
db.init_schema()?;
Ok(db)
Expand Down
Loading