-- btree(chat_id, created_at, id) — выбран в миграции 0001; hot chat, 24294 messages; keyset cursor at 50%
Limit  (cost=0.42..62.81 rows=51 width=213) (actual time=0.032..0.053 rows=51 loops=1)
  Buffers: shared hit=12
  ->  Index Scan using hist_idx on messages  (cost=0.42..15039.53 rows=12293 width=213) (actual time=0.031..0.049 rows=51 loops=1)
        Index Cond: ((chat_id = '0ab807ce-24eb-4da8-8458-ef0836fb3470'::uuid) AND (ROW(created_at, id) > ROW('2026-02-04 13:58:00+03'::timestamp with time zone, 'dc3c4cd9-029a-40dd-976c-64cd71098149'::uuid)))
        Buffers: shared hit=12
Planning:
  Buffers: shared hit=143
Planning Time: 0.506 ms
Execution Time: 0.083 ms

-- same chat, OFFSET 12147
Limit  (cost=6633.54..6633.67 rows=51 width=213) (actual time=32.900..32.912 rows=51 loops=1)
  Buffers: shared hit=3796, temp read=535 written=676
  ->  Sort  (cost=6603.18..6664.33 rows=24460 width=213) (actual time=29.824..32.370 rows=12198 loops=1)
        Sort Key: created_at, id
        Sort Method: external merge  Disk: 5392kB
        Buffers: shared hit=3796, temp read=535 written=676
        ->  Bitmap Heap Scan on messages  (cost=897.98..4820.73 rows=24460 width=213) (actual time=2.958..14.794 rows=24294 loops=1)
              Recheck Cond: (chat_id = '0ab807ce-24eb-4da8-8458-ef0836fb3470'::uuid)
              Heap Blocks: exact=3614
              Buffers: shared hit=3790
              ->  Bitmap Index Scan on hist_idx  (cost=0.00..891.87 rows=24460 width=0) (actual time=2.442..2.442 rows=24294 loops=1)
                    Index Cond: (chat_id = '0ab807ce-24eb-4da8-8458-ef0836fb3470'::uuid)
                    Buffers: shared hit=176
Planning:
  Buffers: shared hit=144
Planning Time: 0.500 ms
Execution Time: 33.741 ms
