messages=10000 -- first page Limit (cost=0.41..13.09 rows=50 width=35) (actual time=0.029..0.055 rows=50 loops=1) Buffers: shared hit=5 -> Index Scan using ix_messages_history on messages (cost=0.41..2506.71 rows=9889 width=35) (actual time=0.028..0.049 rows=50 loops=1) Index Cond: (chat_id = 'f075dcf3-bb90-47bb-be38-504b3d26db6a'::uuid) Buffers: shared hit=5 Planning: Buffers: shared hit=104 Planning Time: 0.340 ms Execution Time: 0.079 ms -- page after row 5000 Limit (cost=0.41..15.86 rows=50 width=35) (actual time=0.031..0.046 rows=50 loops=1) Buffers: shared hit=4 -> Index Scan using ix_messages_history on messages (cost=0.41..2383.08 rows=7713 width=35) (actual time=0.029..0.039 rows=50 loops=1) Index Cond: ((chat_id = 'f075dcf3-bb90-47bb-be38-504b3d26db6a'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.005001+00'::timestamp with time zone, '7e995dee-8c7d-4c9b-a7f7-573c0b88b68b'::uuid))) Buffers: shared hit=4 Planning: Buffers: shared hit=103 Planning Time: 0.335 ms Execution Time: 0.085 ms