BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1996-02-01' and o_orderdate < cast(date '1996-02-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=1301384.51..1301384.52 rows=1 width=16) (actual time=132109.694..132109.695 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=950244 read=585909 dirtied=1240 written=39 -> HashAggregate (cost=1301384.49..1301384.50 rows=1 width=16) (actual time=132109.579..132109.581 rows=5 loops=1) Buffers: shared hit=950239 read=585909 dirtied=1240 written=39 -> Hash Join (cost=1030168.20..1300655.92 rows=145715 width=16) (actual time=113354.732..131691.182 rows=515122 loops=1) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) Buffers: shared hit=950239 read=585909 dirtied=1240 written=39 -> Bitmap Heap Scan on orders (cost=12062.09..277204.98 rows=555326 width=20) (actual time=648.945..6220.781 rows=561691 loops=1) Recheck Cond: ((o_orderdate >= '1996-02-01'::date) AND (o_orderdate < '1996-05-01'::date)) Buffers: shared hit=141165 read=90456 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..11923.25 rows=555326 width=0) (actual time=536.479..536.479 rows=568888 loops=1) Index Cond: ((o_orderdate >= '1996-02-01'::date) AND (o_orderdate < '1996-05-01'::date)) Buffers: shared read=1629 -> Hash (cost=1001476.92..1001476.92 rows=1330336 width=4) (actual time=112703.634..112703.634 rows=13767230 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 484005kB Buffers: shared hit=809074 read=495453 dirtied=1240 written=39 -> HashAggregate (cost=988173.56..1001476.92 rows=1330336 width=4) (actual time=98111.202..107552.842 rows=13767230 loops=1) Buffers: shared hit=809074 read=495453 dirtied=1240 written=39 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.00..937486.18 rows=20274952 width=4) (actual time=0.175..58795.304 rows=37966096 loops=1) Buffers: shared hit=809074 read=495453 dirtied=1240 written=39 Total runtime: 132545.071 ms (23 rows) COMMIT; COMMIT