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-21' and l_shipdate > date '1995-03-21' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2690021.97..2690022.00 rows=10 width=20) (actual time=36540.483..36540.489 rows=10 loops=1) Buffers: shared hit=791389 read=575571 dirtied=128 written=3463 -> Sort (cost=2690021.97..2698010.20 rows=3195291 width=20) (actual time=36540.480..36540.483 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=791389 read=575571 dirtied=128 written=3463 -> HashAggregate (cost=2589019.97..2620972.88 rows=3195291 width=20) (actual time=36461.140..36519.328 rows=113282 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=791383 read=575571 dirtied=128 written=3463 -> Hash Join (cost=555670.39..2541090.61 rows=3195291 width=20) (actual time=10848.641..36189.800 rows=299849 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=791383 read=575571 dirtied=128 written=3463 -> Seq Scan on lineitem (cost=0.00..1831527.48 rows=32517289 width=12) (actual time=0.041..19523.862 rows=32181363 loops=1) Filter: (l_shipdate > '1995-03-21'::date) Rows Removed by Filter: 27802559 Buffers: shared hit=616630 read=458346 -> Hash (cost=537080.03..537080.03 rows=1487229 width=12) (actual time=10833.616..10833.616 rows=1465094 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79338kB Buffers: shared hit=174753 read=117225 dirtied=128 written=3463 -> Hash Join (cost=49885.86..537080.03 rows=1487229 width=12) (actual time=1560.680..10234.939 rows=1465094 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=174753 read=117225 dirtied=128 written=3463 -> Seq Scan on orders (cost=0.00..444735.19 rows=7356449 width=16) (actual time=0.033..5326.791 rows=7327484 loops=1) Filter: (o_orderdate < '1995-03-21'::date) Rows Removed by Filter: 7672516 Buffers: shared hit=174751 read=80797 dirtied=128 written=3409 -> Hash (cost=46095.24..46095.24 rows=303250 width=4) (actual time=873.250..873.250 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=2 read=36428 written=54 -> Bitmap Heap Scan on customer (cost=7026.61..46095.24 rows=303250 width=4) (actual time=80.643..762.817 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=2 read=36428 written=54 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6950.80 rows=303250 width=0) (actual time=70.992..70.992 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 5.834 ms Execution time: 36574.827 ms (38 rows) COMMIT; COMMIT