Purging old data takes quite a while, especially when reducing the purge_keep_days
value
Debug log looks like this:
2023-02-08 00:29:31.800 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: PurgeTask(purge_before=datetime.datetime(2022, 8, 28, 19, 22, 56, 333689, tzinfo=datetime.timezone.utc), repack=False, apply_filter=False)
2023-02-08 00:29:31.800 DEBUG (Recorder) [homeassistant.components.recorder.purge] Purging states and events before target 2022-08-28 19:22:56+00:00
2023-02-08 00:29:31.800 DEBUG (Recorder) [homeassistant.components.recorder.purge] Purge running in new format as there are NO states with event_id remaining
2023-02-08 00:29:31.801 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 state ids and 0 attributes_ids to remove
2023-02-08 00:29:31.801 DEBUG (Recorder) [homeassistant.components.recorder.purge] After purging states and attributes_ids remaining=False
2023-02-08 00:29:31.801 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 event ids and 0 data_ids to remove
2023-02-08 00:29:31.801 DEBUG (Recorder) [homeassistant.components.recorder.purge] After purging event and data_ids remaining=False
2023-02-08 00:29:31.802 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 statistic runs to remove
2023-02-08 00:29:31.804 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 173 short term statistics to remove
2023-02-08 00:29:31.827 DEBUG (Recorder) [homeassistant.components.recorder.purge] Deleted <sqlalchemy.engine.cursor.CursorResult object at 0x7fbceacfaef0> short term statistics
2023-02-08 00:29:31.827 DEBUG (Recorder) [homeassistant.components.recorder.purge] Purging hasn't fully completed yet
2023-02-08 00:29:31.953 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: PurgeTask(purge_before=datetime.datetime(2022, 8, 28, 19, 22, 56, 333689, tzinfo=datetime.timezone.utc), repack=False, apply_filter=False)
2023-02-08 00:29:31.954 DEBUG (Recorder) [homeassistant.components.recorder.purge] Purging states and events before target 2022-08-28 19:22:56+00:00
2023-02-08 00:29:31.955 DEBUG (Recorder) [homeassistant.components.recorder.purge] Purge running in new format as there are NO states with event_id remaining
2023-02-08 00:29:31.956 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 state ids and 0 attributes_ids to remove
2023-02-08 00:29:31.956 DEBUG (Recorder) [homeassistant.components.recorder.purge] After purging states and attributes_ids remaining=False
2023-02-08 00:29:31.956 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 event ids and 0 data_ids to remove
2023-02-08 00:29:31.956 DEBUG (Recorder) [homeassistant.components.recorder.purge] After purging event and data_ids remaining=False
2023-02-08 00:29:31.957 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 statistic runs to remove
2023-02-08 00:29:31.959 DEBUG (Recorder) [homeassistant.components.recorder.purge] Selected 0 short term statistics to remove
2023-02-08 00:29:32.060 DEBUG (Recorder) [homeassistant.components.recorder.purge] Deleted <sqlalchemy.engine.cursor.CursorResult object at 0x7fbcfabb3250> recorder_runs
It would be nice to get a start and end log message with class “INFO”, for very long running tasks.