BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date '1994-03-01' and o_orderdate < cast(date '1994-03-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=1288494.94..1288494.94 rows=1 width=16) (actual time=132022.313..132022.314 rows=5 loops=1) Sort Key: orders.o_orderpriority Sort Method: quicksort Memory: 25kB Buffers: shared hit=1022934 read=479232 dirtied=1065 written=4304 -> HashAggregate (cost=1288494.92..1288494.93 rows=1 width=16) (actual time=132022.112..132022.116 rows=5 loops=1) Buffers: shared hit=1022929 read=479232 dirtied=1065 written=4304 -> Hash Join (cost=1019558.48..1287733.23 rows=152338 width=16) (actual time=114101.485..131608.317 rows=525688 loops=1) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) Buffers: shared hit=1022929 read=479232 dirtied=1065 written=4304 -> Bitmap Heap Scan on orders (cost=12168.18..274810.26 rows=574272 width=20) (actual time=679.381..6689.914 rows=573093 loops=1) Recheck Cond: ((o_orderdate >= '1994-03-01'::date) AND (o_orderdate < '1994-06-01'::date)) Buffers: shared hit=225952 read=4419 -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..12024.62 rows=574272 width=0) (actual time=577.211..577.211 rows=574823 loops=1) Index Cond: ((o_orderdate >= '1994-03-01'::date) AND (o_orderdate < '1994-06-01'::date)) Buffers: shared read=1570 -> Hash (cost=990761.09..990761.09 rows=1330336 width=4) (actual time=113419.872..113419.872 rows=13753462 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 483521kB Buffers: shared hit=796977 read=474813 dirtied=1065 written=4304 -> HashAggregate (cost=977457.73..990761.09 rows=1330336 width=4) (actual time=100094.830..109854.017 rows=13753462 loops=1) Buffers: shared hit=796977 read=474813 dirtied=1065 written=4304 -> Index Scan using lineitem_l_orderkey_idx_part1 on lineitem (cost=0.00..927319.82 rows=20055165 width=4) (actual time=0.248..58372.723 rows=37928885 loops=1) Buffers: shared hit=796977 read=474813 dirtied=1065 written=4304 Total runtime: 132312.556 ms (23 rows) COMMIT; COMMIT