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 = 'MACHINERY' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-25' and l_shipdate > date '1995-03-25' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2697476.13..2697476.15 rows=10 width=20) (actual time=32059.396..32059.399 rows=10 loops=1) Buffers: shared hit=967361 read=404897 written=47 -> Sort (cost=2697476.13..2705387.05 rows=3164368 width=20) (actual time=32059.393..32059.394 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=967361 read=404897 written=47 -> HashAggregate (cost=2597451.59..2629095.27 rows=3164368 width=20) (actual time=31991.745..32038.609 rows=113582 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=967355 read=404897 written=47 -> Hash Join (cost=557154.80..2549986.08 rows=3164368 width=20) (actual time=8320.931..31731.170 rows=300665 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=967355 read=404897 written=47 -> Seq Scan on lineitem (cost=0.00..1838832.43 rows=32628046 width=12) (actual time=0.028..17845.029 rows=32114835 loops=1) Filter: (l_shipdate > '1995-03-25'::date) Rows Removed by Filter: 27930462 Buffers: shared hit=712978 read=366284 -> Hash (cost=538734.19..538734.19 rows=1473649 width=12) (actual time=8307.974..8307.974 rows=1471743 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79623kB Buffers: shared hit=254377 read=38613 written=47 -> Hash Join (cost=49575.77..538734.19 rows=1473649 width=12) (actual time=492.990..7759.412 rows=1471743 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=254377 read=38613 written=47 -> Seq Scan on orders (cost=0.00..446496.39 rows=7446809 width=16) (actual time=0.021..4720.600 rows=7359577 loops=1) Filter: (o_orderdate < '1995-03-25'::date) Rows Removed by Filter: 7655423 Buffers: shared hit=219101 read=37459 written=47 -> Hash (cost=45865.34..45865.34 rows=296835 width=4) (actual time=489.206..489.206 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=35276 read=1154 -> Bitmap Heap Scan on customer (cost=6876.90..45865.34 rows=296835 width=4) (actual time=77.729..402.732 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=35276 read=1154 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6802.69 rows=296835 width=0) (actual time=67.516..67.516 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 3.578 ms Execution time: 32089.585 ms (38 rows) COMMIT; COMMIT