diff options
author | Erik Johnston <erik@matrix.org> | 2022-05-17 10:34:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 09:34:59 +0000 |
commit | 32ef24fbd74b8822c3e57c8ce74b979506aea7be (patch) | |
tree | 3f382ecc962e7f7260c8bd46db8f05179f8a6c39 /synapse/storage/databases | |
parent | Track in memory events using weakrefs (#10533) (diff) | |
download | synapse-32ef24fbd74b8822c3e57c8ce74b979506aea7be.tar.xz |
Add index to cache invalidations (#12747)
For workers that rarely write to the cache the `get_all_updated_caches` query can become expensive if the worker falls behind when reading the cache.
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r-- | synapse/storage/databases/main/cache.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/cache.py b/synapse/storage/databases/main/cache.py index dd4e83a2ad..1653a6a9b6 100644 --- a/synapse/storage/databases/main/cache.py +++ b/synapse/storage/databases/main/cache.py @@ -57,6 +57,14 @@ class CacheInvalidationWorkerStore(SQLBaseStore): self._instance_name = hs.get_instance_name() + self.db_pool.updates.register_background_index_update( + update_name="cache_invalidation_index_by_instance", + index_name="cache_invalidation_stream_by_instance_instance_index", + table="cache_invalidation_stream_by_instance", + columns=("instance_name", "stream_id"), + psql_only=True, # The table is only on postgres DBs. + ) + async def get_all_updated_caches( self, instance_name: str, last_id: int, current_id: int, limit: int ) -> Tuple[List[Tuple[int, tuple]], int, bool]: |