diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 04b1f43bc1b43a10eb042a11d13390d816eafe4b..5e0fb8b59d623060dd1f3bd02411a325e7d6394a 100644 --- a/homeassistant/components/recorder/util.py +++ b/homeassistant/components/recorder/util.py @@ -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