Skip to content

Commit c93b398

Browse files
Increase cache size for sqlite
1 parent e3ea7fd commit c93b398

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/db/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ struct ConnectionCustomizer;
1919
impl CustomizeConnection<Connection, ::rusqlite::Error> for ConnectionCustomizer {
2020
fn on_acquire(&self, conn: &mut Connection) -> Result<(), ::rusqlite::Error> {
2121
conn.execute("PRAGMA foreign_keys = ON;", [])?;
22+
// Increase cache size from ~2 MB (current default) to ~100 MB.
23+
//
24+
// This should help sqlite keep pages in memory rather than needing to
25+
// seek and read. Those typically hit the OS cache, but syscalls are
26+
// still somewhat expensive at these volumes.
27+
conn.execute("PRAGMA cache_size = -100000;", [])?;
2228
Ok(())
2329
}
2430
}

0 commit comments

Comments
 (0)