Limit (cost=6162.88..6165.20 rows=20 width=238) (actual time=12.084..15.940 rows=51.00 loops=1) Buffers: shared hit=4307 -> Gather Merge (cost=6162.88..6186.40 rows=202 width=238) (actual time=12.082..15.934 rows=51.00 loops=1) Workers Planned: 2 Workers Launched: 2 Buffers: shared hit=4307 -> Sort (cost=5162.85..5163.06 rows=84 width=238) (actual time=8.686..8.690 rows=44.33 loops=3) Sort Key: created_at, id Sort Method: quicksort Memory: 57kB Buffers: shared hit=4307 Worker 0: Sort Method: top-N heapsort Memory: 41kB Worker 1: Sort Method: quicksort Memory: 58kB -> Parallel Seq Scan on messages (cost=0.00..5160.17 rows=84 width=238) (actual time=1.775..8.612 rows=100.00 loops=3) Filter: ((chat_id = $1) AND (ROW(created_at, id) > ROW($2, $3))) Rows Removed by Filter: 40273 Buffers: shared hit=4277 Planning: Buffers: shared hit=89 Planning Time: 0.335 ms Execution Time: 16.001 ms