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-10' and l_shipdate > date '1995-03-10' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2744366.51..2744366.53 rows=10 width=20) (actual time=88623.868..88623.872 rows=10 loops=1) Buffers: shared hit=1093867 read=265207 dirtied=67 written=57 -> Sort (cost=2744366.51..2752195.41 rows=3131560 width=20) (actual time=88623.862..88623.864 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=1093867 read=265207 dirtied=67 written=57 -> HashAggregate (cost=2645379.02..2676694.62 rows=3131560 width=20) (actual time=88534.188..88603.643 rows=114165 loops=1) Buffers: shared hit=1093861 read=265207 dirtied=67 written=57 -> Hash Join (cost=624366.78..2598405.62 rows=3131560 width=20) (actual time=33364.156..88019.878 rows=302371 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1093861 read=265207 dirtied=67 written=57 -> Seq Scan on lineitem (cost=0.00..1820677.18 rows=32545617 width=12) (actual time=0.097..30246.220 rows=32490801 loops=1) Filter: (l_shipdate > '1995-03-10'::date) Rows Removed by Filter: 27554578 Buffers: shared hit=885476 read=183132 -> Hash (cost=606271.35..606271.35 rows=1447635 width=12) (actual time=33360.905..33360.905 rows=1456957 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62604kB Buffers: shared hit=208385 read=82075 dirtied=67 written=57 -> Hash Join (cost=49651.57..606271.35 rows=1447635 width=12) (actual time=1649.603..30172.128 rows=1456957 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=208385 read=82075 dirtied=67 written=57 -> Seq Scan on orders (cost=0.00..442089.90 rows=7276620 width=16) (actual time=0.018..8509.653 rows=7265607 loops=1) Filter: (o_orderdate < '1995-03-10'::date) Rows Removed by Filter: 7749393 Buffers: shared hit=208383 read=45645 dirtied=67 written=12 -> Hash (cost=45921.38..45921.38 rows=298415 width=4) (actual time=1649.028..1649.028 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=2 read=36430 written=45 -> Bitmap Heap Scan on customer (cost=6913.20..45921.38 rows=298415 width=4) (actual time=94.280..1305.179 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=2 read=36430 written=45 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6838.59 rows=298415 width=0) (actual time=82.613..82.613 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 88814.124 ms (35 rows) COMMIT; COMMIT