BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1993-09-01' and o_orderdate < cast(date '1993-09-01' + interval '3 month' as date) and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Sort (cost=1151618.10..1151618.10 rows=1 width=16) (actual time=9009.667..9009.668 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=2758045 read=267895 dirtied=353 written=584 -> HashAggregate (cost=1151618.08..1151618.09 rows=1 width=16) (actual time=9009.602..9009.603 rows=5 loops=1) Group Key: orders.o_orderpriority Buffers: shared hit=2758040 read=267895 dirtied=353 written=584 -> Nested Loop Semi Join (cost=12508.69..1150845.36 rows=154544 width=16) (actual time=324.032..8743.091 rows=520544 loops=1) Buffers: shared hit=2758040 read=267895 dirtied=353 written=584 -> Bitmap Heap Scan on orders (cost=12508.13..277454.68 rows=575970 width=20) (actual time=323.946..2155.959 rows=568003 loops=1) Recheck Cond: ((o_orderdate >= '1993-09-01'::date) AND (o_orderdate < '1993-12-01'::date)) Heap Blocks: exact=230146 Buffers: shared hit=186529 read=45260 dirtied=211 written=96 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..12364.14 rows=575970 width=0) (actual time=239.528..239.528 rows=574112 loops=1) Index Cond: ((o_orderdate >= '1993-09-01'::date) AND (o_orderdate < '1993-12-01'::date)) Buffers: shared read=1643 written=5 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.56..4.57 rows=5 width=4) (actual time=0.011..0.011 rows=1 loops=568003) Index Cond: (l_orderkey = orders.o_orderkey) Buffers: shared hit=2571511 read=222635 dirtied=142 written=488 Planning time: 3.196 ms Execution time: 9012.826 ms (21 rows) COMMIT; COMMIT