Rows in test chat: 10000 Position: 0 Limit (cost=0.41..10.95 rows=51 width=70) (actual time=0.061..0.085 rows=51 loops=1) Buffers: shared hit=4 -> Index Scan using messages_history on messages (cost=0.41..2063.98 rows=9985 width=70) (actual time=0.059..0.076 rows=51 loops=1) Index Cond: (chat_id = '969e1211-e475-4545-bd15-7e56dc71896d'::uuid) Buffers: shared hit=4 Planning: Buffers: shared hit=19 Planning Time: 0.220 ms Execution Time: 0.148 ms Position: 5000 Limit (cost=0.41..17.20 rows=51 width=70) (actual time=0.013..0.058 rows=51 loops=1) Buffers: shared hit=5 -> Index Scan using messages_history on messages (cost=0.41..1741.06 rows=5288 width=70) (actual time=0.012..0.050 rows=51 loops=1) Index Cond: ((chat_id = '969e1211-e475-4545-bd15-7e56dc71896d'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.005001+00'::timestamp with time zone, 'fa66b073-e248-4fb4-9603-7515b64b598e'::uuid))) Buffers: shared hit=5 Planning Time: 0.107 ms Execution Time: 0.104 ms Position: 9900 Limit (cost=0.41..94.31 rows=51 width=70) (actual time=0.017..0.029 rows=51 loops=1) Buffers: shared hit=4 -> Index Scan using messages_history on messages (cost=0.41..1324.25 rows=719 width=70) (actual time=0.016..0.025 rows=51 loops=1) Index Cond: ((chat_id = '969e1211-e475-4545-bd15-7e56dc71896d'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.009901+00'::timestamp with time zone, 'b484fd5f-6223-4f33-9f32-7d154df937da'::uuid))) Buffers: shared hit=4 Planning Time: 0.087 ms Execution Time: 0.046 ms PostgreSQL: 16.8 (Debian 16.8-1.pgdg120+1) Durability: on on PASS: actual EXPLAIN ANALYZE BUFFERS at first/middle/tail; API traversal 10000 rows, 100 pages, 1.851s