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

Commit

Permalink
Don't create event_search index on sqlite
Browse files Browse the repository at this point in the history
... because the table is virtual
  • Loading branch information
richvdh committed May 11, 2017
1 parent 114f290 commit 34194aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions synapse/storage/background_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def register_background_update_handler(self, update_name, update_handler):

def register_background_index_update(self, update_name, index_name,
table, columns, where_clause=None,
unique=False):
unique=False,
psql_only=False):
"""Helper for store classes to do a background index addition
To use:
Expand All @@ -227,6 +228,9 @@ def register_background_index_update(self, update_name, index_name,
index_name (str): name of index to add
table (str): table to add index to
columns (list[str]): columns/expressions to include in index
unique (bool): true to make a UNIQUE index
psql_only: true to only create this index on psql databases (useful
for virtual sqlite tables)
"""

def create_index_psql(conn):
Expand Down Expand Up @@ -288,13 +292,16 @@ def create_index_sqlite(conn):

if isinstance(self.database_engine, engines.PostgresEngine):
runner = create_index_psql
elif psql_only:
runner = None
else:
runner = create_index_sqlite

@defer.inlineCallbacks
def updater(progress, batch_size):
logger.info("Adding index %s to %s", index_name, table)
yield self.runWithConnection(runner)
if runner is not None:
logger.info("Adding index %s to %s", index_name, table)
yield self.runWithConnection(runner)
yield self._end_background_update(update_name)
defer.returnValue(1)

Expand Down
1 change: 1 addition & 0 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def __init__(self, hs):
table="event_search",
columns=["event_id"],
unique=True,
psql_only=True,
)

self._event_persist_queue = _EventPeristenceQueue()
Expand Down

0 comments on commit 34194aa

Please sign in to comment.