mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Create indices after insertion
This commit is contained in:
parent
93139a1fb8
commit
9dbe38ea7d
@ -1890,20 +1890,6 @@ class EventsStore(EventFederationStore, EventsWorkerStore, BackgroundUpdateStore
|
|||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
||||||
# create an index on should_delete because later we'll be looking for
|
|
||||||
# the should_delete / shouldn't_delete subsets
|
|
||||||
txn.execute(
|
|
||||||
"CREATE INDEX events_to_purge_should_delete"
|
|
||||||
" ON events_to_purge(should_delete)",
|
|
||||||
)
|
|
||||||
|
|
||||||
# We do joins against events_to_purge for e.g. calculating state
|
|
||||||
# groups to purge, etc., so lets make an index.
|
|
||||||
txn.execute(
|
|
||||||
"CREATE INDEX events_to_purge_id"
|
|
||||||
" ON events_to_purge(event_id)",
|
|
||||||
)
|
|
||||||
|
|
||||||
# First ensure that we're not about to delete all the forward extremeties
|
# First ensure that we're not about to delete all the forward extremeties
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"SELECT e.event_id, e.depth FROM events as e "
|
"SELECT e.event_id, e.depth FROM events as e "
|
||||||
@ -1950,6 +1936,24 @@ class EventsStore(EventFederationStore, EventsWorkerStore, BackgroundUpdateStore
|
|||||||
),
|
),
|
||||||
should_delete_params,
|
should_delete_params,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# We create the indices *after* insertion as that's a lot faster.
|
||||||
|
|
||||||
|
# create an index on should_delete because later we'll be looking for
|
||||||
|
# the should_delete / shouldn't_delete subsets
|
||||||
|
txn.execute(
|
||||||
|
"CREATE INDEX events_to_purge_should_delete"
|
||||||
|
" ON events_to_purge(should_delete)",
|
||||||
|
)
|
||||||
|
|
||||||
|
# We do joins against events_to_purge for e.g. calculating state
|
||||||
|
# groups to purge, etc., so lets make an index.
|
||||||
|
txn.execute(
|
||||||
|
"CREATE INDEX events_to_purge_id"
|
||||||
|
" ON events_to_purge(event_id)",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"SELECT event_id, should_delete FROM events_to_purge"
|
"SELECT event_id, should_delete FROM events_to_purge"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user