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-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2773221.67..2773221.69 rows=10 width=20) (actual time=147044.902..147044.906 rows=10 loops=1) Buffers: shared hit=797826 read=574433 written=4 -> Sort (cost=2773221.67..2781207.85 rows=3194472 width=20) (actual time=147044.897..147044.898 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=797826 read=574433 written=4 -> HashAggregate (cost=2672245.55..2704190.27 rows=3194472 width=20) (actual time=146955.829..147022.067 rows=113392 loops=1) Buffers: shared hit=797820 read=574433 written=4 -> Hash Join (cost=630265.00..2624328.47 rows=3194472 width=20) (actual time=40872.465..146157.249 rows=299548 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=797820 read=574433 written=4 -> Seq Scan on lineitem (cost=0.00..1838822.86 rows=32878905 width=12) (actual time=0.061..79125.128 rows=32564906 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27480391 Buffers: shared hit=507369 read=571893 written=4 -> Hash (cost=611811.02..611811.02 rows=1476318 width=12) (actual time=40870.405..40870.405 rows=1449062 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62265kB Buffers: shared hit=290451 read=2540 -> Hash Join (cost=49840.12..611811.02 rows=1476318 width=12) (actual time=1968.677..39214.058 rows=1449062 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=290451 read=2540 -> Seq Scan on orders (cost=0.00..446496.39 rows=7324461 width=16) (actual time=0.025..15178.697 rows=7247058 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7767942 Buffers: shared hit=256215 read=345 -> Hash (cost=46060.87..46060.87 rows=302340 width=4) (actual time=1968.339..1968.339 rows=300441 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10563kB Buffers: shared hit=34236 read=2195 -> Bitmap Heap Scan on customer (cost=7003.62..46060.87 rows=302340 width=4) (actual time=231.980..1782.835 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared hit=34236 read=2195 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6928.03 rows=302340 width=0) (actual time=218.884..218.884 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1155 Total runtime: 147472.998 ms (35 rows) COMMIT; COMMIT