docker compose --env-file .env exec db psql -U messenger -d messenger -c "EXPLAIN (ANALYZE, BUFFERS) SELECT m.id, m.chat_id, m.sender_id, m.text, m.created_at FROM messages m WHERE m.chat_id = '$MEDIUM' ORDER BY m.created_at ASC, m.id ASC LIMIT 50;" 2>&1 | Tee-Object "$EV5\05-explain-medium-first.txt" QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=0.42..81.19 rows=50 width=110) (actual time=0.038..0.117 rows=50 loops=1) Buffers: shared hit=52 -> Index Scan using idx_messages_chat_created_asc_id on messages m (cost=0.42..7979.45 rows=4939 width=110) (actual time=0.037..0.114 rows=50 loops=1) Index Cond: (chat_id = '237c29c6-9d07-4f3b-b9f0-69b3428f1168'::uuid) Buffers: shared hit=52 Planning: Buffers: shared hit=137 Planning Time: 0.870 ms Execution Time: 0.167 ms (9 rows)