BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-20' and l_shipdate > date '1995-03-20' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2699598.47..2699598.49 rows=10 width=20) (actual time=33240.918..33240.922 rows=10 loops=1) Buffers: shared hit=1042512 read=329747 written=44 -> Sort (cost=2699598.47..2707579.79 rows=3192530 width=20) (actual time=33240.916..33240.918 rows=10 loops=1) Sort Key: (sum((lineitem.l_extendedprice * (1::double precision - lineitem.l_discount)))), orders.o_orderdate Sort Method: top-N heapsort Memory: 25kB Buffers: shared hit=1042512 read=329747 written=44 -> HashAggregate (cost=2598683.74..2630609.04 rows=3192530 width=20) (actual time=33173.803..33219.850 rows=114179 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1042506 read=329747 written=44 -> Hash Join (cost=557356.83..2550795.79 rows=3192530 width=20) (actual time=9019.210..32936.441 rows=302034 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1042506 read=329747 written=44 -> Seq Scan on lineitem (cost=0.00..1838827.16 rows=32716399 width=12) (actual time=0.037..17642.664 rows=32239322 loops=1) Filter: (l_shipdate > '1995-03-20'::date) Rows Removed by Filter: 27805975 Buffers: shared hit=811212 read=268050 written=3 -> Hash (cost=538822.47..538822.47 rows=1482749 width=12) (actual time=9004.548..9004.548 rows=1469536 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79529kB Buffers: shared hit=231294 read=61697 written=41 -> Hash Join (cost=49762.68..538822.47 rows=1482749 width=12) (actual time=754.551..8406.064 rows=1469536 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=231294 read=61697 written=41 -> Seq Scan on orders (cost=0.00..446496.39 rows=7396243 width=16) (actual time=0.023..4649.670 rows=7328465 loops=1) Filter: (o_orderdate < '1995-03-20'::date) Rows Removed by Filter: 7686535 Buffers: shared hit=231292 read=25268 -> Hash (cost=46003.81..46003.81 rows=300710 width=4) (actual time=751.077..751.077 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=41 -> Bitmap Heap Scan on customer (cost=6966.93..46003.81 rows=300710 width=4) (actual time=70.189..648.563 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=41 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6891.75 rows=300710 width=0) (actual time=61.447..61.447 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 3.817 ms Execution time: 33265.597 ms (38 rows) COMMIT; COMMIT