summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2023-05-02 15:52:30 +0100
committerErik Johnston <erik@matrix.org>2023-05-02 15:52:30 +0100
commit2e25777a82f8e78b6ddbea37395802e244c7871b (patch)
treeb2c1f082eba969fe9227ce44f1f4ec8826d9c7a6 /synapse
parentReduce the size of the HTTP connection pool for non-pushers. (#15514) (diff)
downloadsynapse-2e25777a82f8e78b6ddbea37395802e244c7871b.tar.xz
Ensure we always use index
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/databases/main/event_push_actions.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py
index eeccf5db24..6fdb1e292e 100644
--- a/synapse/storage/databases/main/event_push_actions.py
+++ b/synapse/storage/databases/main/event_push_actions.py
@@ -1836,6 +1836,15 @@ class EventPushActionsWorkerStore(ReceiptsWorkerStore, StreamWorkerStore, SQLBas
             # deletes.
             batch_size = self._rotate_count
 
+            if isinstance(self.database_engine, PostgresEngine):
+                # Temporarily disable sequential scans in this transaction. We
+                # need to do this as the postgres statistics don't take into
+                # account the `highlight = 0` part when estimating the
+                # distribution of `stream_ordering`. I.e. since we keep old
+                # highlight rows the query planner thinks there are way more old
+                # rows to delete than there actually are.
+                txn.execute("SET LOCAL enable_seqscan=off")
+
             txn.execute(
                 """
                 SELECT stream_ordering FROM event_push_actions