Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

purge_history cleanups #2867

Merged
merged 4 commits into from
Feb 15, 2018
Merged

purge_history cleanups #2867

merged 4 commits into from
Feb 15, 2018

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Feb 14, 2018

  • fix index use
  • use a temporary table, which should speed things up by reducing the amount of data being shuffled across the connection

... which should speed things up by reducing the amount of data being shuffled
across the connection
event_push_actions doesn't have an index on event_id, so we need to specify
room_id.
# create an index on should_delete because later we'll be looking for
# the should_delete / shouldn't_delete subsets
txn.execute("CREATE INDEX ON events_to_purge(should_delete)")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs suggest analyzing temp tables if you're going to do complex queries on it. Not sure if that applies in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I'd prefer to avoid that if possible, because it will need special-casing to just be postgres (because sqlite will commit the txn on analyze). Let's see how it works in practice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Feb 14, 2018
apparently creating a temporary table commits the transaction. because that's a
useful thing.
apparently sqlite insists on indexes being named
"CREATE TEMPORARY TABLE events_to_purge ("
" event_id TEXT NOT NULL,"
" should_delete BOOLEAN NOT NULL"
")"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just use """ triple quotes rather than quoting each line individually fwiw

@richvdh richvdh merged commit b8d821a into develop Feb 15, 2018
@richvdh richvdh deleted the rav/rework_purge branch May 2, 2018 15:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants