BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1997-09-01' and o_orderdate < cast(date '1997-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=1295090.91..1295090.91 rows=1 width=16) (actual time=83691.533..83691.535 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=952516 read=561035 dirtied=1062 written=686 -> HashAggregate (cost=1295090.89..1295090.90 rows=1 width=16) (actual time=83691.389..83691.390 rows=5 loops=1) Buffers: shared hit=952511 read=561035 dirtied=1062 written=686 -> Hash Join (cost=1024826.51..1294315.80 rows=155017 width=16) (actual time=71542.906..83332.457 rows=519671 loops=1) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) Buffers: shared hit=952511 read=561035 dirtied=1062 written=686 -> Bitmap Heap Scan on orders (cost=12480.93..276414.40 rows=575898 width=20) (actual time=509.765..2908.309 rows=567035 loops=1) Recheck Cond: ((o_orderdate >= '1997-09-01'::date) AND (o_orderdate < '1997-12-01'::date)) Buffers: shared hit=227939 read=2771 written=186 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..12336.96 rows=575898 width=0) (actual time=377.983..377.983 rows=570857 loops=1) Index Cond: ((o_orderdate >= '1997-09-01'::date) AND (o_orderdate < '1997-12-01'::date)) Buffers: shared hit=94 read=1535 -> Hash (cost=995387.56..995387.56 rows=1356641 width=4) (actual time=71031.085..71031.085 rows=13767175 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 484003kB Buffers: shared hit=724572 read=558264 dirtied=1062 written=500 -> HashAggregate (cost=981821.15..995387.56 rows=1356641 width=4) (actual time=56464.934..66624.373 rows=13767175 loops=1) Buffers: shared hit=724572 read=558264 dirtied=1062 written=500 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.00..931434.07 rows=20154834 width=4) (actual time=0.147..25655.078 rows=37965693 loops=1) Buffers: shared hit=724572 read=558264 dirtied=1062 written=500 Total runtime: 83990.913 ms (23 rows) COMMIT; COMMIT