66 lines
3.9 KiB
Plaintext
66 lines
3.9 KiB
Plaintext
# EXPLAIN (ANALYZE, BUFFERS): история сообщений, рабочий индекс messages_chat_history_idx
|
|
# {"date": "2026-10-29T09:19:19Z", "docker_cpus": 12, "docker_memory_gib": 1.9, "docker_server": "27.2.0", "postgres": "17.11", "shared_buffers": "128MB"}
|
|
# messages: 200000; big chat: 100000, medium: 3000, small: 10
|
|
|
|
## big_first
|
|
SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = '60993bbf-7c34-4ffe-9cd5-da5471b4387b' ORDER BY created_at, id LIMIT 51
|
|
Limit (cost=0.42..27.46 rows=51 width=464) (actual time=0.034..0.056 rows=51 loops=1)
|
|
Buffers: shared hit=9
|
|
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..53460.07 rows=100847 width=464) (actual time=0.034..0.052 rows=51 loops=1)
|
|
Index Cond: (chat_id = '60993bbf-7c34-4ffe-9cd5-da5471b4387b'::uuid)
|
|
Buffers: shared hit=9
|
|
Planning:
|
|
Buffers: shared hit=140
|
|
Planning Time: 1.713 ms
|
|
Execution Time: 0.106 ms
|
|
|
|
## big_d90_keyset
|
|
SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = '60993bbf-7c34-4ffe-9cd5-da5471b4387b' AND (created_at, id) > ('2026-09-28 00:28:21.157057+00', 'c0c9ed9c-be61-4384-8a45-bae9a536e6bf') ORDER BY created_at, id LIMIT 51
|
|
Limit (cost=0.42..143.81 rows=51 width=464) (actual time=0.036..0.061 rows=51 loops=1)
|
|
Buffers: shared hit=11
|
|
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..27913.79 rows=9928 width=464) (actual time=0.035..0.056 rows=51 loops=1)
|
|
Index Cond: ((chat_id = '60993bbf-7c34-4ffe-9cd5-da5471b4387b'::uuid) AND (ROW(created_at, id) > ROW('2026-09-28 00:28:21.157057+00'::timestamp with time zone, 'c0c9ed9c-be61-4384-8a45-bae9a536e6bf'::uuid)))
|
|
Buffers: shared hit=11
|
|
Planning:
|
|
Buffers: shared hit=139
|
|
Planning Time: 1.479 ms
|
|
Execution Time: 0.144 ms
|
|
|
|
## big_d90_offset
|
|
SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = '60993bbf-7c34-4ffe-9cd5-da5471b4387b' ORDER BY created_at, id OFFSET 90000 LIMIT 51
|
|
Limit (cost=36460.92..36461.04 rows=1 width=464) (actual time=112.111..123.230 rows=51 loops=1)
|
|
Buffers: shared hit=12711, temp read=5508 written=5850
|
|
I/O Timings: temp read=7.753 write=67.976
|
|
-> Gather Merge (cost=26655.57..36460.92 rows=84040 width=464) (actual time=83.327..120.582 rows=90051 loops=1)
|
|
Workers Planned: 2
|
|
Workers Launched: 2
|
|
Buffers: shared hit=12711, temp read=5508 written=5850
|
|
I/O Timings: temp read=7.753 write=67.976
|
|
-> Sort (cost=25655.55..25760.60 rows=42020 width=464) (actual time=77.801..83.567 rows=30068 loops=3)
|
|
Sort Key: created_at, id
|
|
Sort Method: external merge Disk: 15832kB
|
|
Buffers: shared hit=12711, temp read=5508 written=5850
|
|
I/O Timings: temp read=7.753 write=67.976
|
|
Worker 0: Sort Method: external merge Disk: 16424kB
|
|
Worker 1: Sort Method: external merge Disk: 14416kB
|
|
-> Parallel Seq Scan on messages (cost=0.00..13664.67 rows=42020 width=464) (actual time=0.012..17.673 rows=33333 loops=3)
|
|
Filter: (chat_id = '60993bbf-7c34-4ffe-9cd5-da5471b4387b'::uuid)
|
|
Rows Removed by Filter: 33333
|
|
Buffers: shared hit=12623
|
|
Planning:
|
|
Buffers: shared hit=140
|
|
Planning Time: 1.732 ms
|
|
Execution Time: 129.398 ms
|
|
|
|
## small_first
|
|
SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = '60557307-b3a2-4910-b148-88898ec43ea1' ORDER BY created_at, id LIMIT 51
|
|
Limit (cost=0.42..50.93 rows=12 width=464) (actual time=0.038..0.104 rows=10 loops=1)
|
|
Buffers: shared hit=13
|
|
-> Index Scan using messages_chat_history_idx on messages (cost=0.42..50.93 rows=12 width=464) (actual time=0.037..0.103 rows=10 loops=1)
|
|
Index Cond: (chat_id = '60557307-b3a2-4910-b148-88898ec43ea1'::uuid)
|
|
Buffers: shared hit=13
|
|
Planning:
|
|
Buffers: shared hit=140
|
|
Planning Time: 1.721 ms
|
|
Execution Time: 0.149 ms
|