mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-13 06:02:18 -04:00
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.
This commit is contained in:
parent
fcf951d5dc
commit
32ef24fbd7
3 changed files with 27 additions and 0 deletions
|
@ -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]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue