QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=6279.67..6285.42 rows=50 width=66) (actual time=7.323..8.152 rows=50 loops=1) Buffers: shared hit=1063 read=72 -> Gather Merge (cost=6279.67..11696.05 rows=47099 width=66) (actual time=7.322..8.148 rows=50 loops=1) Workers Planned: 1 Workers Launched: 1 Buffers: shared hit=1063 read=72 -> Sort (cost=5279.66..5397.40 rows=47099 width=66) (actual time=6.368..6.368 rows=26 loops=2) Sort Key: created_at, id Sort Method: top-N heapsort Memory: 38kB Buffers: shared hit=1063 read=72 Worker 0: Sort Method: top-N heapsort Memory: 38kB -> Parallel Index Scan using ix_messages_chat_only on messages (cost=0.42..3715.06 rows=47099 width=66) (actual time=0.031..2.837 rows=40000 loops=2) --More-- Index Cond: (chat_id = '66666666-6666-4666-8666-66666666666--More-- 6'::uuid) --More-- Buffers: shared hit=1048 read=72 --More-- Planning: --More-- Buffers: shared hit=98 read=1 --More-- Planning Time: 0.335 ms --More-- Execution Time: 8.200 ms --More-- (18 rows) --More--