QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.42..12.78 rows=51 width=64) (actual time=0.011..0.027 rows=51 loops=1) Buffers: shared hit=5 -> Index Scan using messages_history_idx on messages (cost=0.42..16814.89 rows=69375 width=64) (actual time=0.010..0.024 rows=51 loops=1) Index Cond: ((chat_id = '136ef7de-de6a-40ec-b0dc-95d805396a72'::uuid) AND (ROW(created_at, id) > ROW('2024-06-01 00:00:00.005+00'::timestamp with time zone, '56ab725d-bf82-4831-aa7d-81c3f4bd290f'::uuid))) Buffers: shared hit=5 Planning: Buffers: shared hit=136 Planning Time: 0.279 ms Execution Time: 0.051 ms (9 rows)