Call sqlite pragma optimize during periodic cleanup task (#91245)
https://www.sqlite.org/pragma.html#pragma_optimize > To achieve the best long-term query performance without the need to do a detailed engineering analysis of the application schema and SQL, it is recommended that applications run "PRAGMA optimize" (with no arguments) just before closing each database connection. Long-running applications might also benefit from setting a timer to run "PRAGMA optimize" every few hours. > This pragma is usually a no-op or nearly so and is very fast. Since we keep the recorder connection open for the entire time HA is running we fall into the long-running application bucket
This commit is contained in:
parent
4e6937d20f
commit
e40a373c4b
1 changed files with 1 additions and 0 deletions
|
@ -673,6 +673,7 @@ def periodic_db_cleanups(instance: Recorder) -> None:
|
|||
_LOGGER.debug("WAL checkpoint")
|
||||
with instance.engine.connect() as connection:
|
||||
connection.execute(text("PRAGMA wal_checkpoint(TRUNCATE);"))
|
||||
connection.execute(text("PRAGMA OPTIMIZE;"))
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue