mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 22:26:19 +00:00
añadir optimizaciones sqlite
This commit is contained in:
parent
d93d5c2055
commit
cf52da7445
2 changed files with 8 additions and 1 deletions
|
@ -15,4 +15,8 @@ export function migrateDb(db) {
|
||||||
migrate(db, { migrationsFolder: path });
|
migrate(db, { migrationsFolder: path });
|
||||||
db.run(sql`pragma journal_mode = WAL;`);
|
db.run(sql`pragma journal_mode = WAL;`);
|
||||||
db.run(sql`PRAGMA synchronous = NORMAL;`);
|
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;`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
|
||||||
use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
|
use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
|
||||||
|
@ -24,6 +24,9 @@ impl Db {
|
||||||
SqliteConnectOptions::from_str(&format!("sqlite://{}", db_path))?
|
SqliteConnectOptions::from_str(&format!("sqlite://{}", db_path))?
|
||||||
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
||||||
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
|
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
|
||||||
|
.busy_timeout(Duration::from_secs(15))
|
||||||
|
.pragma("cache_size", "1000000000")
|
||||||
|
.pragma("temp_store", "memory")
|
||||||
.optimize_on_close(true, None),
|
.optimize_on_close(true, None),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
Loading…
Reference in a new issue