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-26' and l_shipdate > date '1995-03-26' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2689679.06..2689679.09 rows=10 width=20) (actual time=34016.491..34016.496 rows=10 loops=1) Buffers: shared hit=855413 read=511547 written=6 -> Sort (cost=2689679.06..2697661.44 rows=3192952 width=20) (actual time=34016.487..34016.488 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=855413 read=511547 written=6 -> HashAggregate (cost=2588751.00..2620680.52 rows=3192952 width=20) (actual time=33935.294..33996.036 rows=113528 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=855407 read=511547 written=6 -> Hash Join (cost=555935.64..2540856.72 rows=3192952 width=20) (actual time=9003.774..33676.287 rows=300568 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=855407 read=511547 written=6 -> Seq Scan on lineitem (cost=0.00..1831531.31 rows=32389399 width=12) (actual time=0.079..18633.853 rows=32089115 loops=1) Filter: (l_shipdate > '1995-03-26'::date) Rows Removed by Filter: 27954967 Buffers: shared hit=563429 read=511547 written=6 -> Hash (cost=537285.54..537285.54 rows=1492008 width=12) (actual time=8991.895..8991.895 rows=1472847 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79671kB Buffers: shared hit=291978 -> Hash Join (cost=49803.99..537285.54 rows=1492008 width=12) (actual time=620.862..8445.687 rows=1472847 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291978 -> Seq Scan on orders (cost=0.00..444735.19 rows=7420342 width=16) (actual time=0.023..4697.340 rows=7365834 loops=1) Filter: (o_orderdate < '1995-03-26'::date) Rows Removed by Filter: 7649166 Buffers: shared hit=255548 -> Hash (cost=46033.93..46033.93 rows=301605 width=4) (actual time=490.456..490.456 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=36430 -> Bitmap Heap Scan on customer (cost=6985.87..46033.93 rows=301605 width=4) (actual time=63.501..393.358 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=36430 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.47 rows=301605 width=0) (actual time=54.293..54.293 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=1154 Planning time: 3.855 ms Execution time: 34040.501 ms (38 rows) COMMIT; COMMIT