BEGIN DROP INDEX CREATE INDEX ANALYZE QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=0.49..12.45 rows=51 width=64) (actual time=0.321..0.389 rows=51 loops=1) Buffers: shared hit=698 read=4 -> Incremental Sort (cost=0.49..16387.23 rows=69872 width=64) (actual time=0.320..0.385 rows=51 loops=1) Sort Key: created_at, id Presorted Key: created_at Full-sort Groups: 2 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB Buffers: shared hit=698 read=4 -> Index Scan using messages_created_idx on messages (cost=0.29..13242.99 rows=69872 width=64) (actual time=0.067..0.371 rows=52 loops=1) Index Cond: (created_at >= '2024-06-01 00:00:00.005+00'::timestamp with time zone) Filter: ((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))) Rows Removed by Filter: 1173 Buffers: shared hit=698 read=4 Planning: Buffers: shared hit=48 read=3 Planning Time: 0.180 ms Execution Time: 0.419 ms (16 rows) ROLLBACK