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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-09' and l_shipdate > date '1995-03-09' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2678195.57..2678195.60 rows=10 width=20) (actual time=36277.936..36277.941 rows=10 loops=1) Buffers: shared hit=845224 read=515160 dirtied=109 written=202 -> Sort (cost=2678195.57..2686159.44 rows=3185545 width=20) (actual time=36277.931..36277.933 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=845224 read=515160 dirtied=109 written=202 -> HashAggregate (cost=2577501.64..2609357.09 rows=3185545 width=20) (actual time=36195.069..36256.315 rows=114087 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=845218 read=515160 dirtied=109 written=202 -> Hash Join (cost=552637.09..2529718.47 rows=3185545 width=20) (actual time=9319.460..35911.077 rows=302245 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=845218 read=515160 dirtied=109 written=202 -> Seq Scan on lineitem (cost=0.00..1822482.89 rows=32731478 width=12) (actual time=0.028..19312.882 rows=32483876 loops=1) Filter: (l_shipdate > '1995-03-09'::date) Rows Removed by Filter: 27501905 Buffers: shared hit=629376 read=440290 dirtied=1 written=7 -> Hash (cost=534316.00..534316.00 rows=1465687 width=12) (actual time=9306.305..9306.305 rows=1454360 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78877kB Buffers: shared hit=215842 read=74870 dirtied=108 written=195 -> Hash Join (cost=49816.18..534316.00 rows=1465687 width=12) (actual time=761.698..8691.079 rows=1454360 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=215842 read=74870 dirtied=108 written=195 -> Seq Scan on orders (cost=0.00..442530.20 rows=7283400 width=16) (actual time=0.027..4779.778 rows=7252253 loops=1) Filter: (o_orderdate < '1995-03-09'::date) Rows Removed by Filter: 7747747 Buffers: shared hit=213870 read=40411 dirtied=108 written=195 -> Hash (cost=46042.99..46042.99 rows=301855 width=4) (actual time=758.601..758.601 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=1972 read=34459 -> Bitmap Heap Scan on customer (cost=6991.80..46042.99 rows=301855 width=4) (actual time=74.275..652.543 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=1972 read=34459 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6916.34 rows=301855 width=0) (actual time=64.982..64.982 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 3.653 ms Execution time: 36304.083 ms (38 rows) COMMIT; COMMIT