From 6e95d4a02314722bb55822fe63c7e5a74f036d99 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 24 Jan 2024 13:32:16 +0000 Subject: [PATCH 1/2] Run ANALYZE after fiddling with stats --- .../delta/84/01_auth_links_stats.sql.postgres | 2 ++ .../delta/84/03_auth_links_analyze.sql.postgres | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 synapse/storage/schema/main/delta/84/03_auth_links_analyze.sql.postgres diff --git a/synapse/storage/schema/main/delta/84/01_auth_links_stats.sql.postgres b/synapse/storage/schema/main/delta/84/01_auth_links_stats.sql.postgres index b0b41bd106..0c3ae979eb 100644 --- a/synapse/storage/schema/main/delta/84/01_auth_links_stats.sql.postgres +++ b/synapse/storage/schema/main/delta/84/01_auth_links_stats.sql.postgres @@ -16,3 +16,5 @@ -- figuring that out by itself. ALTER TABLE event_auth_chain_links ALTER origin_chain_id SET (n_distinct = -0.5); ALTER TABLE event_auth_chain_links ALTER target_chain_id SET (n_distinct = -0.5); + +-- We should have done an `ANALYZE event_auth_chain_links` here, but we forgot. diff --git a/synapse/storage/schema/main/delta/84/03_auth_links_analyze.sql.postgres b/synapse/storage/schema/main/delta/84/03_auth_links_analyze.sql.postgres new file mode 100644 index 0000000000..aecb72a477 --- /dev/null +++ b/synapse/storage/schema/main/delta/84/03_auth_links_analyze.sql.postgres @@ -0,0 +1,16 @@ +-- +-- This file is licensed under the Affero General Public License (AGPL) version 3. +-- +-- Copyright (C) 2023 New Vector, Ltd +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- See the GNU Affero General Public License for more details: +-- . + +-- We need to do an ANALYZE after `01_auth_links_stats.sql.postgres`, where we +-- fiddled with the stats. +ANALYZE event_auth_chain_links; From b960779000fa9b561798471bab020a229454ae1b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 24 Jan 2024 13:33:55 +0000 Subject: [PATCH 2/2] Newsfile --- changelog.d/16849.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/16849.bugfix diff --git a/changelog.d/16849.bugfix b/changelog.d/16849.bugfix new file mode 100644 index 0000000000..1bbe2b9ad8 --- /dev/null +++ b/changelog.d/16849.bugfix @@ -0,0 +1 @@ +Fix database performance regression due to changing Postgres table statistics. Introduced in v1.100.0rc1.