Rows in test chat: 10000 Position: 0 Limit (cost=0.29..4.17 rows=51 width=70) (actual time=0.013..0.029 rows=51 loops=1) Buffers: shared hit=3 -> Index Scan using messages_history on messages (cost=0.29..762.03 rows=10000 width=70) (actual time=0.012..0.022 rows=51 loops=1) Index Cond: (chat_id = 'afb33e87-5203-44cd-8aaa-6352dd299bff'::uuid) Buffers: shared hit=3 Planning: Buffers: shared hit=20 Planning Time: 0.229 ms Execution Time: 0.049 ms Position: 5000 Limit (cost=0.29..5.43 rows=51 width=70) (actual time=0.011..0.023 rows=51 loops=1) Buffers: shared hit=4 -> Index Scan using messages_history on messages (cost=0.29..503.22 rows=4981 width=70) (actual time=0.010..0.018 rows=51 loops=1) Index Cond: ((chat_id = 'afb33e87-5203-44cd-8aaa-6352dd299bff'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.005001+00'::timestamp with time zone, '0c66c126-2dbf-49ff-a50d-6ffe6d9b9d0c'::uuid))) Buffers: shared hit=4 Planning Time: 0.146 ms Execution Time: 0.053 ms Position: 9900 Limit (cost=0.29..68.37 rows=51 width=70) (actual time=0.086..0.104 rows=51 loops=1) Buffers: shared hit=3 -> Index Scan using messages_history on messages (cost=0.29..135.12 rows=101 width=70) (actual time=0.085..0.097 rows=51 loops=1) Index Cond: ((chat_id = 'afb33e87-5203-44cd-8aaa-6352dd299bff'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.009901+00'::timestamp with time zone, '1f3e9d78-d453-4240-8e54-585c7ee9e9a6'::uuid))) Buffers: shared hit=3 Planning Time: 0.150 ms Execution Time: 0.131 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.907s