Timing is on. Time: 8.859 ms COMPOSITE INDEX QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=0.42..6.06 rows=50 width=46) (actual time=0.028..0.039 rows=50 loops=1) Buffers: shared hit=5 -> Index Scan using idx_messages_chat_created_id on messages (cost=0.42..11162.90 rows=98962 width=46) (actual time=0.027..0.036 rows=50 loops=1) Index Cond: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid) Buffers: shared hit=5 Planning: Buffers: shared hit=14 Planning Time: 0.097 ms Execution Time: 0.048 ms (9 rows) Time: 0.507 ms BEGIN Time: 0.083 ms CREATE INDEX Time: 0.205 ms DROP INDEX Time: 0.680 ms SINGLE COLUMN INDEX QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=5448.46..5454.21 rows=50 width=46) (actual time=13.704..14.946 rows=50 loops=1) Buffers: shared hit=114 read=1543 -> Gather Merge (cost=5448.46..12142.95 rows=58213 width=46) (actual time=13.703..14.938 rows=50 loops=1) Workers Planned: 1 Workers Launched: 1 Buffers: shared hit=114 read=1543 -> Sort (cost=4448.45..4593.98 rows=58213 width=46) (actual time=12.461..12.463 rows=50 loops=2) Sort Key: created_at, id Sort Method: top-N heapsort Memory: 28kB Buffers: shared hit=114 read=1543 Worker 0: Sort Method: top-N heapsort Memory: 28kB -> Parallel Seq Scan on messages (cost=0.00..2514.65 rows=58213 width=46) (actual time=0.012..8.363 rows=45002 loops=2) Filter: (chat_id = 'f68eff95-e44f-4c79-997c-49eb725cfb4d'::uuid) Rows Removed by Filter: 16310 Buffers: shared hit=70 read=1543 Planning: Buffers: shared hit=4 Planning Time: 0.038 ms Execution Time: 14.977 ms (19 rows) Time: 15.268 ms ROLLBACK Time: 0.138 ms ORIGINAL INDEX RESTORED