añadir optimizaciones sqlite

This commit is contained in:
Cat /dev/Nulo 2024-04-04 10:50:34 -03:00
parent d93d5c2055
commit cf52da7445
2 changed files with 8 additions and 1 deletions

View file

@ -15,4 +15,8 @@ export function migrateDb(db) {
migrate(db, { migrationsFolder: path });
db.run(sql`pragma journal_mode = WAL;`);
db.run(sql`PRAGMA synchronous = NORMAL;`);
db.run(sql`PRAGMA busy_timeout = 15000;`);
db.run(sql`PRAGMA cache_size = 1000000000;`);
// db.run(sql`PRAGMA foreign_keys = true;`);
db.run(sql`PRAGMA temp_store = memory;`);
}

View file

@ -1,7 +1,7 @@
use std::{
env,
str::FromStr,
time::{SystemTime, UNIX_EPOCH},
time::{Duration, SystemTime, UNIX_EPOCH},
};
use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
@ -24,6 +24,9 @@ impl Db {
SqliteConnectOptions::from_str(&format!("sqlite://{}", db_path))?
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
.busy_timeout(Duration::from_secs(15))
.pragma("cache_size", "1000000000")
.pragma("temp_store", "memory")
.optimize_on_close(true, None),
)
.await?;