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-18' and l_shipdate > date '1995-03-18' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2668757.84..2668757.87 rows=10 width=20) (actual time=27960.023..27960.027 rows=10 loops=1) Buffers: shared hit=802615 read=553818 -> Sort (cost=2668757.84..2676662.86 rows=3162009 width=20) (actual time=27960.011..27960.012 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=802615 read=553818 -> HashAggregate (cost=2568807.87..2600427.96 rows=3162009 width=20) (actual time=27905.398..27941.146 rows=113474 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=802609 read=553818 -> Hash Join (cost=551529.01..2521377.74 rows=3162009 width=20) (actual time=7176.897..27705.907 rows=300241 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=802609 read=553818 -> Seq Scan on lineitem (cost=0.00..1817043.30 rows=32316091 width=12) (actual time=0.026..16040.742 rows=32290776 loops=1) Filter: (l_shipdate > '1995-03-18'::date) Rows Removed by Filter: 27754893 Buffers: shared hit=513811 read=552664 -> Hash (cost=533164.51..533164.51 rows=1469160 width=12) (actual time=7169.316..7169.316 rows=1462627 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79232kB Buffers: shared hit=288798 read=1154 -> Hash Join (cost=49745.74..533164.51 rows=1469160 width=12) (actual time=427.336..6692.827 rows=1462627 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288798 read=1154 -> Seq Scan on orders (cost=0.00..441209.30 rows=7338097 width=16) (actual time=0.017..4304.321 rows=7315744 loops=1) Filter: (o_orderdate < '1995-03-18'::date) Rows Removed by Filter: 7699256 Buffers: shared hit=253522 -> Hash (cost=45991.81..45991.81 rows=300315 width=4) (actual time=425.042..425.042 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=35276 read=1154 -> Bitmap Heap Scan on customer (cost=6959.87..45991.81 rows=300315 width=4) (actual time=66.678..348.326 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=35276 read=1154 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6884.79 rows=300315 width=0) (actual time=58.249..58.249 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 5.627 ms Execution time: 27983.760 ms (38 rows) COMMIT; COMMIT