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=2682923.22..2682923.24 rows=10 width=20) (actual time=36715.237..36715.241 rows=10 loops=1) Buffers: shared hit=973699 read=390635 written=16 -> Sort (cost=2682923.22..2690813.81 rows=3156237 width=20) (actual time=36715.233..36715.235 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=973699 read=390635 written=16 -> HashAggregate (cost=2583155.70..2614718.07 rows=3156237 width=20) (actual time=36645.067..36694.358 rows=114014 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=973693 read=390635 written=16 -> Hash Join (cost=553840.39..2535812.14 rows=3156237 width=20) (actual time=10735.657..36330.501 rows=301970 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=973693 read=390635 written=16 -> Seq Scan on lineitem (cost=0.00..1827919.74 rows=32663906 width=12) (actual time=0.030..18409.934 rows=32457480 loops=1) Filter: (l_shipdate > '1995-03-10'::date) Rows Removed by Filter: 27527429 Buffers: shared hit=718649 read=354207 written=5 -> Hash (cost=535595.94..535595.94 rows=1459556 width=12) (actual time=10720.501..10720.501 rows=1455457 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78924kB Buffers: shared hit=255044 read=36428 written=11 -> Hash Join (cost=49672.78..535595.94 rows=1459556 width=12) (actual time=753.471..10043.636 rows=1455457 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=255044 read=36428 written=11 -> Seq Scan on orders (cost=0.00..443852.85 rows=7326599 width=16) (actual time=0.025..4750.640 rows=7258474 loops=1) Filter: (o_orderdate < '1995-03-10'::date) Rows Removed by Filter: 7741526 Buffers: shared hit=255041 -> Hash (cost=45937.53..45937.53 rows=298820 width=4) (actual time=749.752..749.752 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=3 read=36428 written=11 -> Bitmap Heap Scan on customer (cost=6924.28..45937.53 rows=298820 width=4) (actual time=70.658..651.537 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=3 read=36428 written=11 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6849.58 rows=298820 width=0) (actual time=61.988..61.988 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 written=1 Planning time: 3.786 ms Execution time: 36749.137 ms (38 rows) COMMIT; COMMIT