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-12' and l_shipdate > date '1995-03-12' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2776556.07..2776556.10 rows=10 width=20) (actual time=83261.976..83261.981 rows=10 loops=1) Buffers: shared hit=790246 read=584640 written=52 -> Sort (cost=2776556.07..2784477.49 rows=3168568 width=20) (actual time=83261.971..83261.974 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=790246 read=584640 written=52 -> HashAggregate (cost=2676398.78..2708084.46 rows=3168568 width=20) (actual time=83174.482..83240.304 rows=114118 loops=1) Buffers: shared hit=790240 read=584640 written=52 -> Hash Join (cost=631423.78..2628870.26 rows=3168568 width=20) (actual time=26628.704..82639.684 rows=302067 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=790240 read=584640 written=52 -> Seq Scan on lineitem (cost=0.00..1842441.31 rows=32885195 width=12) (actual time=0.085..31130.366 rows=32440212 loops=1) Filter: (l_shipdate > '1995-03-12'::date) Rows Removed by Filter: 27604581 Buffers: shared hit=501288 read=580094 -> Hash (cost=613086.86..613086.86 rows=1466954 width=12) (actual time=26626.029..26626.029 rows=1459506 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62714kB Buffers: shared hit=288952 read=4546 written=52 -> Hash Join (cost=49651.57..613086.86 rows=1466954 width=12) (actual time=889.050..25318.679 rows=1459506 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288952 read=4546 written=52 -> Seq Scan on orders (cost=0.00..447376.99 rows=7373728 width=16) (actual time=0.027..6875.728 rows=7278161 loops=1) Filter: (o_orderdate < '1995-03-12'::date) Rows Removed by Filter: 7736839 Buffers: shared hit=253682 read=3384 written=27 -> Hash (cost=45921.38..45921.38 rows=298415 width=4) (actual time=888.752..888.752 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=35270 read=1162 written=25 -> Bitmap Heap Scan on customer (cost=6913.20..45921.38 rows=298415 width=4) (actual time=118.997..731.213 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=35270 read=1162 written=25 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6838.59 rows=298415 width=0) (actual time=106.397..106.397 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=2 read=1153 written=25 Total runtime: 83313.866 ms (35 rows) COMMIT; COMMIT