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=2770324.20..2770324.22 rows=10 width=20) (actual time=84390.163..84390.167 rows=10 loops=1) Buffers: shared hit=701544 read=669388 -> Sort (cost=2770324.20..2778281.29 rows=3182838 width=20) (actual time=84390.159..84390.161 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=701544 read=669388 -> HashAggregate (cost=2669715.83..2701544.21 rows=3182838 width=20) (actual time=84251.259..84362.623 rows=113564 loops=1) Buffers: shared hit=701538 read=669388 -> Hash Join (cost=631498.97..2621973.26 rows=3182838 width=20) (actual time=27356.769..83709.196 rows=300597 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=701538 read=669388 -> Seq Scan on lineitem (cost=0.00..1837006.71 rows=32437120 width=12) (actual time=0.069..31800.524 rows=32115065 loops=1) Filter: (l_shipdate > '1995-03-25'::date) Rows Removed by Filter: 27929929 Buffers: shared hit=409969 read=668219 -> Hash (cost=612880.16..612880.16 rows=1489505 width=12) (actual time=27353.672..27353.672 rows=1471652 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63236kB Buffers: shared hit=291569 read=1169 -> Hash Join (cost=49762.24..612880.16 rows=1489505 width=12) (actual time=831.230..26151.432 rows=1471652 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291569 read=1169 -> Seq Scan on orders (cost=0.00..446056.09 rows=7430311 width=16) (actual time=0.032..7267.396 rows=7359453 loops=1) Filter: (o_orderdate < '1995-03-25'::date) Rows Removed by Filter: 7655547 Buffers: shared hit=256296 read=11 -> Hash (cost=46003.55..46003.55 rows=300695 width=4) (actual time=830.887..830.887 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=35273 read=1158 -> Bitmap Heap Scan on customer (cost=6966.87..46003.55 rows=300695 width=4) (actual time=117.431..699.511 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=35273 read=1158 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6891.69 rows=300695 width=0) (actual time=104.863..104.863 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 84442.538 ms (35 rows) COMMIT; COMMIT