--- Q1 первая страница большого чата (80 000), keyset
                                   QUERY PLAN                                    
---------------------------------------------------------------------------------
 Limit (actual rows=51 loops=1)
   Buffers: shared hit=55
   ->  Index Only Scan using ix_t2_covering on messages (actual rows=51 loops=1)
         Index Cond: (chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid)
         Heap Fetches: 51
         Buffers: shared hit=55
 Planning:
   Buffers: shared hit=161
 Planning Time: 0.806 ms
 Execution Time: 0.234 ms
(10 rows)

--- Q2 страница из середины большого чата, keyset
                                                                                                    QUERY PLAN                                                                                                    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit (actual rows=51 loops=1)
   Buffers: shared hit=55
   ->  Index Only Scan using ix_t2_covering on messages (actual rows=51 loops=1)
         Index Cond: ((chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 11:06:24+00'::timestamp with time zone, '3126d0c5-166f-481e-96bf-c950463908dc'::uuid)))
         Heap Fetches: 51
         Buffers: shared hit=55
 Planning Time: 0.073 ms
 Execution Time: 0.230 ms
(8 rows)

--- Q3 последняя страница большого чата, keyset
                                                                                                    QUERY PLAN                                                                                                    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit (actual rows=32 loops=1)
   Buffers: shared hit=35
   ->  Index Only Scan using ix_t2_covering on messages (actual rows=32 loops=1)
         Index Cond: ((chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 22:12:48+00'::timestamp with time zone, 'c8a497c3-78fd-44f5-8bc7-3abcc4d06d1d'::uuid)))
         Heap Fetches: 32
         Buffers: shared hit=35
 Planning Time: 0.077 ms
 Execution Time: 0.117 ms
(8 rows)

--- Q4 маленький чат (5 сообщений)
                                   QUERY PLAN                                   
--------------------------------------------------------------------------------
 Limit (actual rows=5 loops=1)
   Buffers: shared hit=8
   ->  Index Only Scan using ix_t2_covering on messages (actual rows=5 loops=1)
         Index Cond: (chat_id = 'a7223743-6f48-4880-9b67-0e0cc8635177'::uuid)
         Heap Fetches: 5
         Buffers: shared hit=8
 Planning Time: 0.067 ms
 Execution Time: 0.050 ms
(8 rows)

--- Q5 середина большого чата, OFFSET 40000 (для сравнения с keyset)
                                      QUERY PLAN                                      
--------------------------------------------------------------------------------------
 Limit (actual rows=51 loops=1)
   Buffers: shared hit=40672
   ->  Index Only Scan using ix_t2_covering on messages m (actual rows=40051 loops=1)
         Index Cond: (chat_id = '60e7163e-605c-470b-81c0-820c332cfec7'::uuid)
         Heap Fetches: 40051
         Buffers: shared hit=40672
 Planning Time: 0.056 ms
 Execution Time: 19.230 ms
(8 rows)

