diff --git a/lib/Database.php b/lib/Database.php index cc2a032..393b226 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -9,6 +9,15 @@ class Database self::$handle = new SQLite3(SQLITE_DB); self::$handle->enableExceptions(true); + $initialQueries = [ + "PRAGMA journal_mode = WAL", + "PRAGMA synchronous = OFF", + "PRAGMA cache_size = 10000", + "PRAGMA temp_store = MEMORY" + ]; + + self::$handle->exec(implode(";", $initialQueries) . ";"); + if ($createDatabase === true) { $this->createDatabase(); @@ -97,6 +106,9 @@ class Database if ($migrationCount > 0) { Logger::log("Ran " . $migrationCount . " migrations", LOGGER::DEBUG, "Database"); + + self::$handle->exec("PRAGMA optimize;"); + Logger::log("Optimized database", LOGGER::DEBUG, "Database"); } else { Logger::log("No migrations to run", LOGGER::DEBUG, "Database"); }