105 lines
4.8 KiB
Markdown
105 lines
4.8 KiB
Markdown
# Track 2: EXPLAIN (ANALYZE, BUFFERS)
|
|
|
|
## big chat
|
|
```
|
|
Limit (cost=4726.04..4731.85 rows=51 width=69) (actual time=28.316..32.077 rows=51.00 loops=1)
|
|
Buffers: shared hit=1639
|
|
-> Gather Merge (cost=4726.04..9161.77 rows=38920 width=69) (actual time=28.313..32.066 rows=51.00 loops=1)
|
|
Workers Planned: 1
|
|
Workers Launched: 1
|
|
Buffers: shared hit=1639
|
|
-> Sort (cost=3726.03..3783.26 rows=22894 width=69) (actual time=6.294..6.298 rows=25.50 loops=2)
|
|
Sort Key: created_at, id
|
|
Sort Method: top-N heapsort Memory: 38kB
|
|
Buffers: shared hit=1639
|
|
Worker 0: Sort Method: quicksort Memory: 25kB
|
|
-> Parallel Seq Scan on messages (cost=0.00..2962.24 rows=22894 width=69) (actual time=0.010..4.738 rows=13636.50 loops=2)
|
|
Filter: ((chat_id = '79d37065-bfb0-4cb1-8f1e-e79533f724ff'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 15:03:17.148852+03'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))
|
|
Rows Removed by Filter: 51364
|
|
Buffers: shared hit=1624
|
|
Planning:
|
|
Buffers: shared hit=88
|
|
Planning Time: 1.487 ms
|
|
Execution Time: 32.133 ms
|
|
|
|
```
|
|
|
|
## small chat
|
|
```
|
|
Limit (cost=3899.08..3899.09 rows=6 width=69) (actual time=7.785..7.787 rows=1.00 loops=1)
|
|
Buffers: shared hit=1630
|
|
-> Sort (cost=3899.08..3899.09 rows=6 width=69) (actual time=7.783..7.783 rows=1.00 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: quicksort Memory: 25kB
|
|
Buffers: shared hit=1630
|
|
-> Seq Scan on messages (cost=0.00..3899.00 rows=6 width=69) (actual time=0.056..7.764 rows=1.00 loops=1)
|
|
Filter: ((chat_id = '730e474b-405e-4558-8cf3-ac6a17c2a7d1'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 01:23:13.456347+03'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))
|
|
Rows Removed by Filter: 129999
|
|
Buffers: shared hit=1624
|
|
Planning:
|
|
Buffers: shared hit=88
|
|
Planning Time: 1.182 ms
|
|
Execution Time: 7.820 ms
|
|
|
|
```
|
|
|
|
## no_index
|
|
```
|
|
Limit (cost=4475.27..4475.40 rows=51 width=69) (actual time=12.589..12.596 rows=51.00 loops=1)
|
|
Buffers: shared hit=729
|
|
-> Sort (cost=4475.27..4572.12 rows=38739 width=69) (actual time=12.587..12.589 rows=51.00 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: top-N heapsort Memory: 38kB
|
|
Buffers: shared hit=729
|
|
-> Bitmap Heap Scan on messages (cost=609.04..3182.85 rows=38739 width=69) (actual time=0.891..8.050 rows=27273.00 loops=1)
|
|
Recheck Cond: (chat_id = '79d37065-bfb0-4cb1-8f1e-e79533f724ff'::uuid)
|
|
Filter: (ROW(created_at, id) > ROW('2026-10-02 15:03:17.148852+03'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid))
|
|
Rows Removed by Filter: 27272
|
|
Heap Blocks: exact=675
|
|
Buffers: shared hit=723
|
|
-> Bitmap Index Scan on idx_messages_chat_only (cost=0.00..599.36 rows=54275 width=0) (actual time=0.823..0.823 rows=54545.00 loops=1)
|
|
Index Cond: (chat_id = '79d37065-bfb0-4cb1-8f1e-e79533f724ff'::uuid)
|
|
Index Searches: 1
|
|
Buffers: shared hit=48
|
|
Planning:
|
|
Buffers: shared hit=100
|
|
Planning Time: 2.045 ms
|
|
Execution Time: 12.641 ms
|
|
|
|
```
|
|
|
|
## chat_only
|
|
```
|
|
Limit (cost=23.89..23.91 rows=8 width=69) (actual time=0.037..0.037 rows=1.00 loops=1)
|
|
Buffers: shared hit=9
|
|
-> Sort (cost=23.89..23.91 rows=8 width=69) (actual time=0.035..0.035 rows=1.00 loops=1)
|
|
Sort Key: created_at, id
|
|
Sort Method: quicksort Memory: 25kB
|
|
Buffers: shared hit=9
|
|
-> Index Scan using idx_messages_chat_only on messages (cost=0.29..23.77 rows=8 width=69) (actual time=0.015..0.015 rows=1.00 loops=1)
|
|
Index Cond: (chat_id = '730e474b-405e-4558-8cf3-ac6a17c2a7d1'::uuid)
|
|
Filter: (ROW(created_at, id) > ROW('2026-10-02 01:23:13.456347+03'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid))
|
|
Index Searches: 1
|
|
Buffers: shared hit=3
|
|
Planning:
|
|
Buffers: shared hit=100
|
|
Planning Time: 2.240 ms
|
|
Execution Time: 0.066 ms
|
|
|
|
```
|
|
|
|
## full (chat_id, created_at, id)
|
|
```
|
|
Limit (cost=0.42..9.42 rows=51 width=69) (actual time=0.101..0.118 rows=51.00 loops=1)
|
|
Buffers: shared hit=5 read=1
|
|
-> Index Scan using idx_messages_chat_created on messages (cost=0.42..6871.59 rows=38939 width=69) (actual time=0.098..0.112 rows=51.00 loops=1)
|
|
Index Cond: ((chat_id = '79d37065-bfb0-4cb1-8f1e-e79533f724ff'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 15:03:17.148852+03'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))
|
|
Index Searches: 1
|
|
Buffers: shared hit=5 read=1
|
|
Planning:
|
|
Buffers: shared hit=111
|
|
Planning Time: 1.697 ms
|
|
Execution Time: 0.153 ms
|
|
|
|
```
|