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=2689857.35..2689857.37 rows=10 width=20) (actual time=32357.180..32357.186 rows=10 loops=1) Buffers: shared hit=703376 read=663584 dirtied=70 written=66 -> Sort (cost=2689857.35..2697848.30 rows=3196383 width=20) (actual time=32357.176..32357.178 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=703376 read=663584 dirtied=70 written=66 -> HashAggregate (cost=2588820.83..2620784.66 rows=3196383 width=20) (actual time=32283.322..32336.653 rows=113594 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=703370 read=663584 dirtied=70 written=66 -> Hash Join (cost=556088.05..2540875.08 rows=3196383 width=20) (actual time=8841.770..32033.976 rows=300610 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=703370 read=663584 dirtied=70 written=66 -> Seq Scan on lineitem (cost=0.00..1831531.76 rows=32344385 width=12) (actual time=0.029..17628.914 rows=32113994 loops=1) Filter: (l_shipdate > '1995-03-25'::date) Rows Removed by Filter: 27930088 Buffers: shared hit=489107 read=585869 written=1 -> Hash (cost=537391.92..537391.92 rows=1495690 width=12) (actual time=8830.320..8830.320 rows=1471622 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79618kB Buffers: shared hit=214263 read=77715 dirtied=70 written=65 -> Hash Join (cost=49803.50..537391.92 rows=1495690 width=12) (actual time=475.607..8307.900 rows=1471622 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=214263 read=77715 dirtied=70 written=65 -> Seq Scan on orders (cost=0.00..444735.19 rows=7439023 width=16) (actual time=0.024..4735.157 rows=7359680 loops=1) Filter: (o_orderdate < '1995-03-25'::date) Rows Removed by Filter: 7655320 Buffers: shared hit=179002 read=76546 dirtied=70 written=63 -> Hash (cost=46033.62..46033.62 rows=301590 width=4) (actual time=472.108..472.108 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=35261 read=1169 written=2 -> Bitmap Heap Scan on customer (cost=6985.75..46033.62 rows=301590 width=4) (actual time=72.543..377.049 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=35261 read=1169 written=2 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.35 rows=301590 width=0) (actual time=63.617..63.617 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 written=2 Planning time: 3.621 ms Execution time: 32375.775 ms (38 rows) COMMIT; COMMIT