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

--- Q2 страница из середины большого чата, keyset
                                                                                                    QUERY PLAN                                                                                                    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit (actual rows=51 loops=1)
   Buffers: shared hit=54
   ->  Index Scan using ix_t2_hist 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)))
         Buffers: shared hit=54
 Planning Time: 0.088 ms
 Execution Time: 0.209 ms
(7 rows)

--- Q3 последняя страница большого чата, keyset
                                                                                                    QUERY PLAN                                                                                                    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Limit (actual rows=32 loops=1)
   Buffers: shared hit=35
   ->  Index Scan using ix_t2_hist 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)))
         Buffers: shared hit=35
 Planning Time: 0.094 ms
 Execution Time: 0.131 ms
(7 rows)

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

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

