Skip to content

Commit

Permalink
añadir optimizaciones sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
catdevnull committed Apr 4, 2024
1 parent d93d5c2 commit cf52da7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions db-datos/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;`);
}
5 changes: 4 additions & 1 deletion scraper-rs/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
env,
str::FromStr,
time::{SystemTime, UNIX_EPOCH},
time::{Duration, SystemTime, UNIX_EPOCH},
};

use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
Expand All @@ -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?;
Expand Down

0 comments on commit cf52da7

Please sign in to comment.