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-28' and l_shipdate > date '1995-03-28' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2689638.98..2689639.00 rows=10 width=20) (actual time=33848.696..33848.700 rows=10 loops=1) Buffers: shared hit=710445 read=656515 written=176 -> Sort (cost=2689638.98..2697622.44 rows=3193384 width=20) (actual time=33848.692..33848.693 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=710445 read=656515 written=176 -> HashAggregate (cost=2588697.26..2620631.10 rows=3193384 width=20) (actual time=33772.368..33827.093 rows=113491 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=710439 read=656515 written=176 -> Hash Join (cost=556018.64..2540796.50 rows=3193384 width=20) (actual time=9116.666..33510.474 rows=300315 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=710439 read=656515 written=176 -> Seq Scan on lineitem (cost=0.00..1831531.31 rows=32350055 width=12) (actual time=0.033..18381.941 rows=32038740 loops=1) Filter: (l_shipdate > '1995-03-28'::date) Rows Removed by Filter: 28005342 Buffers: shared hit=541908 read=533068 written=17 -> Hash (cost=537343.33..537343.33 rows=1494025 width=12) (actual time=9105.388..9105.388 rows=1475289 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79776kB Buffers: shared hit=168531 read=123447 written=159 -> Hash Join (cost=49803.99..537343.33 rows=1494025 width=12) (actual time=835.510..8550.314 rows=1475289 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=168531 read=123447 written=159 -> Seq Scan on orders (cost=0.00..444735.19 rows=7430373 width=16) (actual time=0.024..5213.420 rows=7378191 loops=1) Filter: (o_orderdate < '1995-03-28'::date) Rows Removed by Filter: 7636809 Buffers: shared hit=168529 read=87019 written=76 -> Hash (cost=46033.93..46033.93 rows=301605 width=4) (actual time=832.305..832.305 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=2 read=36428 written=83 -> Bitmap Heap Scan on customer (cost=6985.87..46033.93 rows=301605 width=4) (actual time=78.789..733.950 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=2 read=36428 written=83 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6910.47 rows=301605 width=0) (actual time=69.112..69.112 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 4.398 ms Execution time: 33873.979 ms (38 rows) COMMIT; COMMIT