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-19' and l_shipdate > date '1995-03-19' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2698122.51..2698122.54 rows=10 width=20) (actual time=41132.797..41132.802 rows=10 loops=1) Buffers: shared hit=703480 read=667451 written=121 -> Sort (cost=2698122.51..2706138.23 rows=3206285 width=20) (actual time=41132.790..41132.792 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=703480 read=667451 written=121 -> HashAggregate (cost=2596773.00..2628835.85 rows=3206285 width=20) (actual time=41029.584..41110.988 rows=113323 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=703474 read=667451 written=121 -> Hash Join (cost=557088.88..2548678.72 rows=3206285 width=20) (actual time=10279.955..38213.056 rows=300208 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=703474 read=667451 written=121 -> Seq Scan on lineitem (cost=0.00..1837000.04 rows=32673856 width=12) (actual time=0.053..20068.272 rows=32264690 loops=1) Filter: (l_shipdate > '1995-03-19'::date) Rows Removed by Filter: 27780304 Buffers: shared hit=522031 read=556157 written=4 -> Hash (cost=538468.80..538468.80 rows=1489606 width=12) (actual time=10261.399..10261.399 rows=1464055 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79293kB Buffers: shared hit=181443 read=111294 written=117 -> Hash Join (cost=49885.86..538468.80 rows=1489606 width=12) (actual time=850.171..9606.666 rows=1464055 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=181443 read=111294 written=117 -> Seq Scan on orders (cost=0.00..446056.09 rows=7368210 width=16) (actual time=0.025..5491.567 rows=7322162 loops=1) Filter: (o_orderdate < '1995-03-19'::date) Rows Removed by Filter: 7692838 Buffers: shared hit=181441 read=74866 written=82 -> Hash (cost=46095.24..46095.24 rows=303250 width=4) (actual time=846.347..846.347 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=79.329..739.378 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=69.678..69.678 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 written=5 Planning time: 4.485 ms Execution time: 41160.864 ms (38 rows) COMMIT; COMMIT