Added example: Show top 20 rooms by new events count in last

Alexey Murz Korepov 2020-05-12 10:07:24 +03:00
parent 35b648609b
commit 9b8cc17cb1
1 changed files with 7 additions and 0 deletions

@ -64,6 +64,13 @@ device_lists_stream - 326903
user_directory_search - 316433 user_directory_search - 316433
``` ```
## Show top 20 rooms by new events count in last 1 day:
```
SELECT e.room_id, r.name, COUNT(e.event_id) cnt FROM events e
LEFT JOIN room_stats_state r USING (room_id)
WHERE e.origin_server_ts >= DATE_PART('epoch', NOW() - INTERVAL '1 day') * 1000 GROUP BY e.room_id, r.name ORDER BY cnt DESC LIMIT 20;
```
## Show top 20 users on homeserver by sent events (messages) at last month: ## Show top 20 users on homeserver by sent events (messages) at last month:
``` ```
SELECT user_id, SUM(total_events) SELECT user_id, SUM(total_events)