Skip to content

Commit

Permalink
Try optimizing the database before closing the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Jan 25, 2024
1 parent 1807255 commit 549d6b8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions SQLiteDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ public function __construct($dbname, $schemadir, $sqlitehelper = null)
Functions::register($this->pdo);
}

/**
* Try optimizing the database before closing the connection.
*
* @see https://www.sqlite.org/pragma.html#pragma_optimize
*/
public function __destruct()
{
try {
$this->exec("PRAGMA analysis_limit=400");
$this->exec('PRAGMA optimize;');
} catch (\Exception $e) {
// ignore failures, this is not essential and not available until 3.18.0.
}
}

/**
* Do not serialize the DB connection
*
Expand Down

0 comments on commit 549d6b8

Please sign in to comment.