Show last 100 messages from needed user

Alexey Murz Korepov 2020-06-17 20:02:33 +03:00
parent 48b071d260
commit 7a9cff60e6
1 changed files with 11 additions and 0 deletions

@ -81,6 +81,17 @@ SELECT user_id, SUM(total_events)
LIMIT 20;
```
## Show last 100 messages from needed user, with room names:
```
SELECT e.room_id, r.name, e.event_id, e.type, e.content, j.json FROM events e
LEFT JOIN event_json j USING (room_id)
LEFT JOIN room_stats_state r USING (room_id)
WHERE sender = '@LOGIN:example.com'
AND e.type = 'm.room.message'
ORDER BY stream_ordering DESC
LIMIT 100;
```
## Show top 20 larger tables by storage size
```
SELECT nspname || '.' || relname AS "relation",