Added query for state_group_events with room names

Alexey Murz Korepov 2020-11-16 13:14:07 +03:00
parent 3ee19bb8f8
commit cf737bd22b
1 changed files with 9 additions and 10 deletions

@ -8,15 +8,6 @@ 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
FROM room_stats s
LEFT JOIN room_names r USING (room_id)
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 SELECT r.name, s.room_id, s.current_state_events
FROM room_stats_current s FROM room_stats_current s
@ -25,7 +16,15 @@ SELECT r.name, s.room_id, s.current_state_events
LIMIT 20; LIMIT 20;
``` ```
and by state_group_events count _(join removed for performance reasons)_: and by state_group_events count:
```
SELECT 's.room_id', count('s.room_id') cnt, 'rs.name' FROM state_groups_state s
LEFT JOIN room_stats_current rs USING (room_id)
GROUP BY s.room_id
ORDER BY count(s.room_id) DESC
LIMIT 20;
```
plus same, but with 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
GROUP BY s.room_id GROUP BY s.room_id