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=2665988.30..2665988.32 rows=10 width=20) (actual time=39676.097..39676.100 rows=10 loops=1) Buffers: shared hit=918927 read=437506 dirtied=28 written=1664 -> Sort (cost=2665988.30..2673799.13 rows=3124335 width=20) (actual time=39676.092..39676.093 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=918927 read=437506 dirtied=28 written=1664 -> HashAggregate (cost=2567229.19..2598472.54 rows=3124335 width=20) (actual time=39598.322..39654.620 rows=113491 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=918921 read=437506 dirtied=28 written=1664 -> Hash Join (cost=551022.05..2520364.17 rows=3124335 width=20) (actual time=12748.696..39304.651 rows=300404 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=918921 read=437506 dirtied=28 written=1664 -> Seq Scan on lineitem (cost=0.00..1817046.11 rows=32280708 width=12) (actual time=0.046..19092.328 rows=32133314 loops=1) Filter: (l_shipdate > '1995-03-23'::date) Rows Removed by Filter: 27852015 Buffers: shared hit=736424 read=330051 dirtied=1 written=5 -> Hash (cost=532856.46..532856.46 rows=1453247 width=12) (actual time=12739.520..12739.520 rows=1467518 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79442kB Buffers: shared hit=182497 read=107455 dirtied=27 written=1659 -> Hash Join (cost=49575.77..532856.46 rows=1453247 width=12) (actual time=1114.407..12036.172 rows=1467518 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=182497 read=107455 dirtied=27 written=1659 -> Seq Scan on orders (cost=0.00..441209.30 rows=7343711 width=16) (actual time=0.023..6077.724 rows=7339759 loops=1) Filter: (o_orderdate < '1995-03-23'::date) Rows Removed by Filter: 7660241 Buffers: shared hit=149047 read=104475 dirtied=27 written=1659 -> Hash (cost=45865.34..45865.34 rows=296835 width=4) (actual time=1111.434..1111.434 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=33450 read=2980 -> Bitmap Heap Scan on customer (cost=6876.90..45865.34 rows=296835 width=4) (actual time=171.783..958.802 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=33450 read=2980 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6802.69 rows=296835 width=0) (actual time=154.145..154.145 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 3.432 ms Execution time: 39698.183 ms (38 rows) COMMIT; COMMIT