trying to fixing "show top 20 larger rooms by state events count" query

Pedro hates github.com 2020-04-14 18:07:44 +02:00
parent 91e0af5b91
commit e93d7bfccc
1 changed files with 10 additions and 0 deletions

@ -8,6 +8,7 @@ pg_size_pretty
(1 row) (1 row)
``` ```
## Show top 20 larger rooms by state events count ## Show top 20 larger rooms by state events count
this is old and not working
``` ```
SELECT r.name, s.room_id, s.state_events SELECT r.name, s.room_id, s.state_events
FROM room_stats s FROM room_stats s
@ -15,6 +16,15 @@ SELECT r.name, s.room_id, s.state_events
ORDER BY ts DESC, state_events DESC ORDER BY ts DESC, state_events DESC
LIMIT 20; 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)_: and by state_group_events count _(join removed for performance reasons)_:
``` ```
SELECT s.room_id, count(s.room_id) FROM state_groups_state s SELECT s.room_id, count(s.room_id) FROM state_groups_state s