29 lines
5.7 KiB
Plaintext
29 lines
5.7 KiB
Plaintext
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 = '$SMALL' AND (m.created_at > '2026-09-15 00:00:00+00' OR (m.created_at = '2026-09-15 00:00:00+00' AND m.id > '00000000-0000-0000-0000-000000000000')) ORDER BY m.created_at ASC, m.id ASC LIMIT 50;" 2>&1 | Tee-Object "$EV5\09-explain-small-or.txt"
|
|
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Limit (cost=164.05..164.15 rows=43 width=110) (actual time=0.315..0.320 rows=44 loops=1)
|
|
Buffers: shared hit=27
|
|
-> Sort (cost=164.05..164.15 rows=43 width=110) (actual time=0.313..0.315 rows=44 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: quicksort Memory: 30kB
|
|
Buffers: shared hit=27
|
|
-> Bitmap Heap Scan on messages m (cost=9.30..162.88 rows=43 width=110) (actual time=0.160..0.215 rows=44 loops=1)
|
|
Recheck Cond: (((chat_id = '4356b313-32de-48a1-9a8f-72e84685c264'::uuid) AND (created_at > '2026-09-15 00:00:00+00'::timestamp with time zone)) OR ((chat_id = '4356b313-32de-48a1-9a8f-72e84685c264'::uuid) AND (created_at = '2026-09-15 00:00:00+00'::timestamp with time zone) AND (id > '00000000-0000-0000-0000-000000000000'::uuid)))
|
|
Heap Blocks: exact=15
|
|
Buffers: shared hit=21
|
|
-> BitmapOr (cost=9.30..9.30 rows=43 width=0) (actual time=0.101..0.101 rows=0 loops=1)
|
|
Buffers: shared hit=6
|
|
-> Bitmap Index Scan on idx_messages_chat_created_asc_id (cost=0.00..4.85 rows=43 width=0) (actual time=0.064..0.064 rows=44 loops=1)
|
|
Index Cond: ((chat_id = '4356b313-32de-48a1-9a8f-72e84685c264'::uuid) AND (created_at > '2026-09-15 00:00:00+00'::timestamp with time zone))
|
|
Buffers: shared hit=3
|
|
-> Bitmap Index Scan on idx_messages_chat_created_asc_id (cost=0.00..4.43 rows=1 width=0) (actual time=0.003..0.003 rows=0 loops=1)
|
|
Index Cond: ((chat_id = '4356b313-32de-48a1-9a8f-72e84685c264'::uuid) AND (created_at = '2026-09-15 00:00:00+00'::timestamp with time zone) AND (id > '00000000-0000-0000-0000-000000000000'::uuid))
|
|
Buffers: shared hit=3
|
|
Planning:
|
|
Buffers: shared hit=158
|
|
Planning Time: 1.476 ms
|
|
Execution Time: 0.480 ms
|
|
(22 rows)
|
|
|