@@ -27,14 +27,23 @@ use tokio::sync::{Mutex, Semaphore};
2727const BUSY_TIMEOUT_SECS : u64 = 5 ;
2828
2929/// The maximum number of connections in the database connection pool.
30- const MAX_CONNECTIONS : u32 = 32 ;
30+ const MAX_CONNECTIONS : u32 = 6 ;
3131
3232/// The minimum number of connections in the database connection pool.
33- const MIN_CONNECTIONS : u32 = 5 ;
33+ const MIN_CONNECTIONS : u32 = 2 ;
3434
3535/// The timeout for acquiring a connection from the pool.
3636const ACQUIRE_TIMEOUT_SECS : u64 = 5 ;
3737
38+ /// The cache size in KB
39+ const CACHE_SIZE_KB : & str = "-131072" ; // 128 MB
40+
41+ /// The mmap size in bytes
42+ const MMAP_SIZE_BYTES : & str = "536870912" ; // 512 MB
43+
44+ /// The wal auto checkpoint size in pages
45+ const WAL_AUTO_CHECKPOINT_PAGES : & str = "50000" ; // 200 MB (with default page size of 4 KB)
46+
3847/// A wrapper around `DatabaseInner` which provides retry features.
3948#[ derive( Debug ) ]
4049pub struct Database {
@@ -595,7 +604,11 @@ impl DatabaseInner {
595604 . journal_mode ( sea_orm:: sqlx:: sqlite:: SqliteJournalMode :: Wal )
596605 . busy_timeout ( Duration :: from_secs ( busy_timeout_secs) )
597606 . foreign_keys ( true )
598- . synchronous ( sea_orm:: sqlx:: sqlite:: SqliteSynchronous :: Normal ) ;
607+ . synchronous ( sea_orm:: sqlx:: sqlite:: SqliteSynchronous :: Normal )
608+ . pragma ( "cache_size" , CACHE_SIZE_KB )
609+ . pragma ( "mmap_size" , MMAP_SIZE_BYTES )
610+ . pragma ( "wal_autocheckpoint" , WAL_AUTO_CHECKPOINT_PAGES )
611+ . pragma ( "temp_store" , "MEMORY" ) ;
599612
600613 let sqlx_pool = SqlitePoolOptions :: new ( )
601614 . max_connections ( max_connections)
0 commit comments