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-27' and l_shipdate > date '1995-03-27' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2668759.31..2668759.33 rows=10 width=20) (actual time=38104.410..38104.415 rows=10 loops=1) Buffers: shared hit=495982 read=861775 dirtied=253 written=20 -> Sort (cost=2668759.31..2676588.28 rows=3131590 width=20) (actual time=38104.405..38104.408 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=495982 read=861775 dirtied=253 written=20 -> HashAggregate (cost=2569770.87..2601086.77 rows=3131590 width=20) (actual time=38033.254..38082.475 rows=113553 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=495976 read=861775 dirtied=253 written=20 -> Hash Join (cost=551767.43..2522797.02 rows=3131590 width=20) (actual time=11296.209..37739.867 rows=300615 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=495976 read=861775 dirtied=253 written=20 -> Seq Scan on lineitem (cost=0.00..1818870.86 rows=32224755 width=12) (actual time=0.032..19286.111 rows=32065594 loops=1) Filter: (l_shipdate > '1995-03-27'::date) Rows Removed by Filter: 27980009 Buffers: shared hit=344694 read=722852 written=1 -> Hash (cost=533509.84..533509.84 rows=1460607 width=12) (actual time=11280.163..11280.163 rows=1473997 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79720kB Buffers: shared hit=151282 read=138923 dirtied=253 written=19 -> Hash Join (cost=49575.77..533509.84 rows=1460607 width=12) (actual time=846.116..10595.959 rows=1473997 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=151282 read=138923 dirtied=253 written=19 -> Seq Scan on orders (cost=0.00..441649.60 rows=7380906 width=16) (actual time=0.027..5389.639 rows=7371832 loops=1) Filter: (o_orderdate < '1995-03-27'::date) Rows Removed by Filter: 7643168 Buffers: shared hit=151280 read=102495 dirtied=253 written=2 -> Hash (cost=45865.34..45865.34 rows=296835 width=4) (actual time=842.555..842.555 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=2 read=36428 written=17 -> Bitmap Heap Scan on customer (cost=6876.90..45865.34 rows=296835 width=4) (actual time=82.442..734.953 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=2 read=36428 written=17 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6802.69 rows=296835 width=0) (actual time=73.188..73.188 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 4.660 ms Execution time: 38127.975 ms (38 rows) COMMIT; COMMIT