Skip to content

Commit

Permalink
Optimize history selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Apr 25, 2024
1 parent 8bde367 commit 2418678
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/cleanup_database/history_table_pruner.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ def _run_batch(self, low, high):
self._drop_tmp_table()

def _get_min_max_ids(self):
stmt = text(f"SELECT min(id), max(id) FROM history")
stmt = text(f"SELECT min(id), max(id) FROM history WHERE user_id IS NULL AND hid_counter = 1 AND create_time < :create_time")
params = {"create_time": self.max_create_time}
with self.engine.begin() as conn:
minmax = conn.execute(stmt).all()
minmax = conn.execute(stmt, params).all()
return minmax[0][0], minmax[0][1]

def _mark_histories_as_deleted_and_purged(self, low, high):
Expand Down

0 comments on commit 2418678

Please sign in to comment.