diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 04b1f43bc1b..5e0fb8b59d6 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