--- Q1 первая страница большого чата (80 000), keyset QUERY PLAN ---------------------------------------------------------------------------------------------- Limit (actual rows=51 loops=1) Buffers: shared hit=64 -> Incremental Sort (actual rows=51 loops=1) Sort Key: messages.created_at, messages.id Presorted Key: messages.created_at Full-sort Groups: 2 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB Buffers: shared hit=64 -> Index Scan using ix_t2_nosort on messages (actual rows=52 loops=1) Index Cond: (chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid) Buffers: shared hit=55 Planning: Buffers: shared hit=152 Planning Time: 0.510 ms Execution Time: 0.296 ms (14 rows) --- Q2 страница из середины большого чата, keyset QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=51 loops=1) Buffers: shared hit=56 -> Incremental Sort (actual rows=51 loops=1) Sort Key: messages.created_at, messages.id Presorted Key: messages.created_at Full-sort Groups: 2 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB Buffers: shared hit=56 -> Index Scan using ix_t2_nosort on messages (actual rows=52 loops=1) Index Cond: ((chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid) AND (created_at >= '2026-01-01 11:06:24+00'::timestamp with time zone)) Filter: (ROW(created_at, id) > ROW('2026-01-01 11:06:24+00'::timestamp with time zone, '3126d0c5-166f-481e-96bf-c950463908dc'::uuid)) Rows Removed by Filter: 1 Buffers: shared hit=56 Planning: Buffers: shared hit=9 Planning Time: 0.109 ms Execution Time: 0.278 ms (16 rows) --- Q3 последняя страница большого чата, keyset QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (actual rows=32 loops=1) Buffers: shared hit=36 -> Incremental Sort (actual rows=32 loops=1) Sort Key: messages.created_at, messages.id Presorted Key: messages.created_at Full-sort Groups: 1 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB Buffers: shared hit=36 -> Index Scan using ix_t2_nosort on messages (actual rows=32 loops=1) Index Cond: ((chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid) AND (created_at >= '2026-01-01 22:12:48+00'::timestamp with time zone)) Filter: (ROW(created_at, id) > ROW('2026-01-01 22:12:48+00'::timestamp with time zone, 'c8a497c3-78fd-44f5-8bc7-3abcc4d06d1d'::uuid)) Rows Removed by Filter: 1 Buffers: shared hit=36 Planning Time: 0.104 ms Execution Time: 0.188 ms (14 rows) --- Q4 маленький чат (5 сообщений) QUERY PLAN ------------------------------------------------------------------------------------------------ Limit (actual rows=5 loops=1) Buffers: shared hit=7 -> Sort (actual rows=5 loops=1) Sort Key: messages.created_at, messages.id Sort Method: quicksort Memory: 25kB Buffers: shared hit=7 -> Index Scan using ix_messages_chat_id_sender_id on messages (actual rows=5 loops=1) Index Cond: (chat_id = 'a7223743-6f48-4880-9b67-0e0cc8635177'::uuid) Buffers: shared hit=7 Planning Time: 0.093 ms Execution Time: 0.061 ms (11 rows) --- Q5 середина большого чата, OFFSET 40000 (для сравнения с keyset) QUERY PLAN ------------------------------------------------------------------------------------------------- Limit (actual rows=51 loops=1) Buffers: shared hit=40235 -> Incremental Sort (actual rows=40051 loops=1) Sort Key: created_at, id Presorted Key: created_at Full-sort Groups: 1252 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB Buffers: shared hit=40235 -> Index Scan using ix_t2_nosort on messages m (actual rows=40052 loops=1) Index Cond: (chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid) Buffers: shared hit=40235 Planning Time: 0.070 ms Execution Time: 24.558 ms (12 rows)