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-23' and l_shipdate > date '1995-03-23' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2698029.93..2698029.96 rows=10 width=20) (actual time=38165.977..38165.979 rows=10 loops=1) Buffers: shared hit=746165 read=624766 dirtied=156 written=110 -> Sort (cost=2698029.93..2706048.71 rows=3207511 width=20) (actual time=38165.972..38165.973 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=746165 read=624766 dirtied=156 written=110 -> HashAggregate (cost=2596641.66..2628716.77 rows=3207511 width=20) (actual time=38069.137..38144.318 rows=113526 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=746159 read=624766 dirtied=156 written=110 -> Hash Join (cost=557298.18..2548529.00 rows=3207511 width=20) (actual time=9919.603..37439.253 rows=300577 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=746159 read=624766 dirtied=156 written=110 -> Seq Scan on lineitem (cost=0.00..1837000.04 rows=32574846 width=12) (actual time=0.043..20879.831 rows=32164953 loops=1) Filter: (l_shipdate > '1995-03-23'::date) Rows Removed by Filter: 27880041 Buffers: shared hit=602951 read=475237 written=7 -> Hash (cost=538614.36..538614.36 rows=1494705 width=12) (actual time=9903.933..9903.933 rows=1469149 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79512kB Buffers: shared hit=143208 read=149529 dirtied=156 written=103 -> Hash Join (cost=49885.86..538614.36 rows=1494705 width=12) (actual time=1044.577..9312.364 rows=1469149 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=143208 read=149529 dirtied=156 written=103 -> Seq Scan on orders (cost=0.00..446056.09 rows=7393430 width=16) (actual time=0.034..5685.563 rows=7347115 loops=1) Filter: (o_orderdate < '1995-03-23'::date) Rows Removed by Filter: 7667885 Buffers: shared hit=143206 read=113101 dirtied=156 written=68 -> Hash (cost=46095.24..46095.24 rows=303250 width=4) (actual time=1040.196..1040.196 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=2 read=36428 written=35 -> Bitmap Heap Scan on customer (cost=7026.61..46095.24 rows=303250 width=4) (actual time=115.445..915.728 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=2 read=36428 written=35 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6950.80 rows=303250 width=0) (actual time=103.278..103.278 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 written=2 Planning time: 6.616 ms Execution time: 38204.319 ms (38 rows) COMMIT; COMMIT