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-11' and l_shipdate > date '1995-03-11' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2682862.08..2682862.10 rows=10 width=20) (actual time=36793.127..36793.133 rows=10 loops=1) Buffers: shared hit=801873 read=562461 written=16 -> Sort (cost=2682862.08..2690749.83 rows=3155101 width=20) (actual time=36793.123..36793.127 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=801873 read=562461 written=16 -> HashAggregate (cost=2583130.47..2614681.48 rows=3155101 width=20) (actual time=36703.932..36770.447 rows=114121 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=801867 read=562461 written=16 -> Hash Join (cost=553677.58..2535803.96 rows=3155101 width=20) (actual time=8899.615..36416.700 rows=302059 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=801867 read=562461 written=16 -> Seq Scan on lineitem (cost=0.00..1827915.45 rows=32709312 width=12) (actual time=0.046..19967.868 rows=32465755 loops=1) Filter: (l_shipdate > '1995-03-11'::date) Rows Removed by Filter: 27579555 Buffers: shared hit=558044 read=514812 written=1 -> Hash (cost=535465.01..535465.01 rows=1457005 width=12) (actual time=8891.785..8891.785 rows=1458145 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79039kB Buffers: shared hit=243823 read=47649 written=15 -> Hash Join (cost=49736.01..535465.01 rows=1457005 width=12) (actual time=548.600..8379.895 rows=1458145 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=243823 read=47649 written=15 -> Seq Scan on orders (cost=0.00..443852.85 rows=7281627 width=16) (actual time=0.030..5265.268 rows=7271831 loops=1) Filter: (o_orderdate < '1995-03-11'::date) Rows Removed by Filter: 7743169 Buffers: shared hit=208546 read=46495 written=15 -> Hash (cost=45984.26..45984.26 rows=300140 width=4) (actual time=546.186..546.186 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=35277 read=1154 -> Bitmap Heap Scan on customer (cost=6954.51..45984.26 rows=300140 width=4) (actual time=81.368..458.088 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=35277 read=1154 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.48 rows=300140 width=0) (actual time=71.543..71.543 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 4.215 ms Execution time: 36815.897 ms (38 rows) COMMIT; COMMIT