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-01' and l_shipdate > date '1995-03-01' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2687816.16..2687816.19 rows=10 width=20) (actual time=34157.099..34157.104 rows=10 loops=1) Buffers: shared hit=905441 read=460208 dirtied=1 written=101 -> Sort (cost=2687816.16..2695775.09 rows=3183572 width=20) (actual time=34157.097..34157.099 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=905441 read=460208 dirtied=1 written=101 -> HashAggregate (cost=2587184.60..2619020.32 rows=3183572 width=20) (actual time=34049.605..34136.166 rows=113391 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=905435 read=460208 dirtied=1 written=101 -> Hash Join (cost=554128.66..2539431.02 rows=3183572 width=20) (actual time=8970.516..33779.004 rows=299572 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=905435 read=460208 dirtied=1 written=101 -> Seq Scan on lineitem (cost=0.00..1829728.70 rows=32996783 width=12) (actual time=0.037..18697.404 rows=32714723 loops=1) Filter: (l_shipdate > '1995-03-01'::date) Rows Removed by Filter: 27329941 Buffers: shared hit=706044 read=367874 written=1 -> Hash (cost=535893.71..535893.71 rows=1458796 width=12) (actual time=8958.001..8958.001 rows=1441459 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78322kB Buffers: shared hit=199391 read=92334 dirtied=1 written=100 -> Hash Join (cost=49803.99..535893.71 rows=1458796 width=12) (actual time=806.884..8396.580 rows=1441459 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=199391 read=92334 dirtied=1 written=100 -> Seq Scan on orders (cost=0.00..444294.89 rows=7255166 width=16) (actual time=0.024..5109.910 rows=7209273 loops=1) Filter: (o_orderdate < '1995-03-01'::date) Rows Removed by Filter: 7805727 Buffers: shared hit=199389 read=55906 dirtied=1 written=73 -> Hash (cost=46033.93..46033.93 rows=301605 width=4) (actual time=804.078..804.078 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=2 read=36428 written=27 -> Bitmap Heap Scan on customer (cost=6985.87..46033.93 rows=301605 width=4) (actual time=75.500..709.774 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=2 read=36428 written=27 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.47 rows=301605 width=0) (actual time=66.421..66.421 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 4.766 ms Execution time: 34189.451 ms (38 rows) COMMIT; COMMIT