EXPLAIN (ANALYZE,BUFFERS) SELECT id::text,chat_id::text,sender_id::text,text,created_at FROM messages WHERE chat_id='00000000-0000-4000-8000-000000000001'::uuid AND (created_at,id)>('2026-01-01T00:00:00.072000Z'::timestamptz,'00000000-0000-0000-0000-000000000000'::uuid) ORDER BY messages.created_at,messages.id LIMIT 51; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.42..46.30 rows=51 width=266) (actual time=0.088..0.118 rows=51 loops=1) Buffers: shared hit=5 read=1 -> Index Scan using messages_history_idx on messages (cost=0.42..5657.00 rows=6288 width=266) (actual time=0.088..0.114 rows=51 loops=1) Index Cond: ((chat_id = '00000000-0000-4000-8000-000000000001'::uuid) AND (ROW(created_at, id) > ROW('2026-01-01 00:00:00.072+00'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid))) Buffers: shared hit=5 read=1 Planning: Buffers: shared hit=113 Planning Time: 0.745 ms Execution Time: 0.172 ms (9 rows)