Create index must be on a conn
This commit is contained in:
parent
51bb339ab2
commit
129e403487
|
@ -143,19 +143,26 @@ class SearchStore(BackgroundUpdateStore):
|
||||||
rows_inserted = progress.get("rows_inserted", 0)
|
rows_inserted = progress.get("rows_inserted", 0)
|
||||||
have_added_index = progress['have_added_indexes']
|
have_added_index = progress['have_added_indexes']
|
||||||
|
|
||||||
INSERT_CLUMP_SIZE = 1000
|
if not have_added_index:
|
||||||
|
def create_index(conn):
|
||||||
def reindex_search_txn(txn):
|
conn.rollback()
|
||||||
if not have_added_index:
|
conn.set_session(autocommit=True)
|
||||||
txn.execute(
|
c = conn.cursor()
|
||||||
|
c.execute(
|
||||||
"CREATE INDEX CONCURRENTLY event_search_room_order ON event_search("
|
"CREATE INDEX CONCURRENTLY event_search_room_order ON event_search("
|
||||||
"room_id, origin_server_ts, stream_ordering)"
|
"room_id, origin_server_ts, stream_ordering)"
|
||||||
)
|
)
|
||||||
txn.execute(
|
c.execute(
|
||||||
"CREATE INDEX CONCURRENTLY event_search_order ON event_search("
|
"CREATE INDEX CONCURRENTLY event_search_order ON event_search("
|
||||||
"origin_server_ts, stream_ordering)"
|
"origin_server_ts, stream_ordering)"
|
||||||
)
|
)
|
||||||
|
conn.set_session(autocommit=False)
|
||||||
|
|
||||||
|
yield self.runWithConnection(create_index)
|
||||||
|
|
||||||
|
INSERT_CLUMP_SIZE = 1000
|
||||||
|
|
||||||
|
def reindex_search_txn(txn):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT stream_ordering, origin_server_ts, event_id FROM events"
|
"SELECT stream_ordering, origin_server_ts, event_id FROM events"
|
||||||
" INNER JOIN event_search USING (room_id, event_id)"
|
" INNER JOIN event_search USING (room_id, event_id)"
|
||||||
|
|
Loading…
Reference in New Issue