From e93d7bfcccdc81e5b02f0d2f8eb48046352cbb1b Mon Sep 17 00:00:00 2001 From: "Pedro hates github.com" <39959198+pedro-nonfree@users.noreply.github.com> Date: Tue, 14 Apr 2020 18:07:44 +0200 Subject: [PATCH] trying to fixing "show top 20 larger rooms by state events count" query --- ...analyze-Matrix-Synapse-PostgreSQL-database-stats.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SQL-queries-for-analyze-Matrix-Synapse-PostgreSQL-database-stats.md b/SQL-queries-for-analyze-Matrix-Synapse-PostgreSQL-database-stats.md index 7d5d491..f12fe3f 100644 --- a/SQL-queries-for-analyze-Matrix-Synapse-PostgreSQL-database-stats.md +++ b/SQL-queries-for-analyze-Matrix-Synapse-PostgreSQL-database-stats.md @@ -8,6 +8,7 @@ pg_size_pretty (1 row) ``` ## Show top 20 larger rooms by state events count +this is old and not working ``` SELECT r.name, s.room_id, s.state_events FROM room_stats s @@ -15,6 +16,15 @@ SELECT r.name, s.room_id, s.state_events ORDER BY ts DESC, state_events DESC LIMIT 20; ``` +maybe, in 2020-4-14 this is: +``` +SELECT r.name, s.room_id, s.current_state_events + FROM room_stats_current s + LEFT JOIN room_stats_state r USING (room_id) + ORDER BY current_state_events DESC + LIMIT 20; +``` + and by state_group_events count _(join removed for performance reasons)_: ``` SELECT s.room_id, count(s.room_id) FROM state_groups_state s