Limit (cost=1673.53..1673.58 rows=20 width=238) (actual time=14.400..14.407 rows=51.00 loops=1) Buffers: shared hit=2124 read=53 -> Sort (cost=1673.53..1674.03 rows=202 width=238) (actual time=14.398..14.402 rows=51.00 loops=1) Sort Key: created_at, id Sort Method: top-N heapsort Memory: 44kB Buffers: shared hit=2124 read=53 -> Bitmap Heap Scan on messages (cost=8.89..1665.79 rows=202 width=238) (actual time=13.229..14.305 rows=300.00 loops=1) Recheck Cond: (chat_id = $1) Filter: (ROW(created_at, id) > ROW($2, $3)) Rows Removed by Filter: 59700 Heap Blocks: exact=2118 Buffers: shared hit=2118 read=53 -> Bitmap Index Scan on messages_chat_only (cost=0.00..8.84 rows=606 width=0) (actual time=1.829..1.829 rows=60000.00 loops=1) Index Cond: (chat_id = $1) Index Searches: 1 Buffers: shared read=53 Planning: Buffers: shared hit=97 Planning Time: 0.456 ms Execution Time: 14.511 ms