Optimize sqlite
This commit is contained in:
parent
fe2bc24465
commit
597e9c8dfb
1 changed files with 12 additions and 0 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue