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-13' and l_shipdate > date '1995-03-13' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2767668.53..2767668.55 rows=10 width=20) (actual time=61280.198..61280.203 rows=10 loops=1) Buffers: shared hit=1079609 read=290002 written=10 -> Sort (cost=2767668.53..2775623.17 rows=3181859 width=20) (actual time=61280.193..61280.195 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=1079609 read=290002 written=10 -> HashAggregate (cost=2667091.11..2698909.70 rows=3181859 width=20) (actual time=61190.283..61260.687 rows=113246 loops=1) Buffers: shared hit=1079603 read=290002 written=10 -> Hash Join (cost=629559.43..2619363.22 rows=3181859 width=20) (actual time=22711.064..60877.104 rows=299441 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1079603 read=290002 written=10 -> Seq Scan on lineitem (cost=0.00..1835185.45 rows=32746600 width=12) (actual time=0.036..20403.018 rows=32382539 loops=1) Filter: (l_shipdate > '1995-03-13'::date) Rows Removed by Filter: 27602287 Buffers: shared hit=833087 read=244033 -> Hash (cost=611140.46..611140.46 rows=1473518 width=12) (actual time=22708.729..22708.729 rows=1454999 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62520kB Buffers: shared hit=246516 read=45969 written=10 -> Hash Join (cost=49771.32..611140.46 rows=1473518 width=12) (actual time=709.776..21875.924 rows=1454999 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=246516 read=45969 written=10 -> Seq Scan on orders (cost=0.00..445615.79 rows=7346776 width=16) (actual time=0.012..5179.364 rows=7277217 loops=1) Filter: (o_orderdate < '1995-03-13'::date) Rows Removed by Filter: 7722783 Buffers: shared hit=246513 read=9541 written=10 -> Hash (cost=46010.69..46010.69 rows=300850 width=4) (actual time=709.541..709.541 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=3 read=36428 -> Bitmap Heap Scan on customer (cost=6972.07..46010.69 rows=300850 width=4) (actual time=70.176..609.129 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=3 read=36428 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6896.86 rows=300850 width=0) (actual time=60.997..60.997 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 61318.510 ms (35 rows) COMMIT; COMMIT