@@ -0,0 +1,929 @@
+import logging%0Afrom datetime import datetime, timedelta%0Afrom flexget.utils.simple_persistence import SimplePersistence%0Afrom flexget.event import event%0Afrom flexget import manager%0A%0Alog = logging.getLogger('db_vacuum')%0AVACUUM_INTERVAL = timedelta(weeks=24) # 6 months%0A%0A%0A# Run after the cleanup is actually finished, but before analyze%0A@event('manager.db_cleanup', 1)%0Adef on_cleanup(session):%0A    # Only run vacuum on --cron%0A    if not manager.manager.options.quiet:%0A        return%0A    # Vacuum can take a long time, and is not needed frequently%0A    persistence = SimplePersistence('db_vacuum')%0A    last_vacuum = persistence.get('last_vacuum')%0A    if not last_vacuum or last_vacuum %3C datetime.now() - VACUUM_INTERVAL:%0A        log.info('Running VACUUM on database to improve performance and decrease db size.')%0A        session = manager.Session()%0A        session.execute('VACUUM')%0A        persistence%5B'last_vacuum'%5D = datetime.now()%0A

Implement db_vacuum plugin to reduce database size and improve performance. fix #1407 refs #1167