Advertisement
techblog

optimize_states_table

Aug 16th, 2019
424
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import utils
  2. delete_states = """
  3. delete FROM hassdb.states where entity_id in (select entity_id from hassdb.states where
  4. entity_id in ('sensor.memory_free', 'sensor.processor_use', 'sensor.time', 'sensor.ram_available', 'sensor.cpu_used', 'sensor.cpu_speed', 'sensor.ram_free')
  5. or entity_id like '%docker%' and last_updated < DATE_SUB( NOW() , INTERVAL 0 DAY ));
  6. """
  7.  
  8. utils.execute(delete_states)
  9. utils.execute('optimize TABLE hassdb.states;')
Advertisement
RAW Paste Data Copied
Advertisement