-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
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.
synapse/storage/events.py
Outdated
# 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)") | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair
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" | ||
")" |
There was a problem hiding this comment.
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