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-04' and l_shipdate > date '1995-03-04' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2672183.32..2672183.34 rows=10 width=20) (actual time=30106.300..30106.304 rows=10 loops=1) Buffers: shared hit=1158752 read=199006 dirtied=1068 written=2 -> Sort (cost=2672183.32..2680101.27 rows=3167181 width=20) (actual time=30106.296..30106.298 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=1158752 read=199006 dirtied=1068 written=2 -> HashAggregate (cost=2572069.86..2603741.67 rows=3167181 width=20) (actual time=30043.114..30087.515 rows=114071 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1158746 read=199006 dirtied=1068 written=2 -> Hash Join (cost=551393.93..2524562.15 rows=3167181 width=20) (actual time=8684.331..29812.337 rows=301843 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1158746 read=199006 dirtied=1068 written=2 -> Seq Scan on lineitem (cost=0.00..1818868.06 rows=32700892 width=12) (actual time=0.038..15303.765 rows=32640999 loops=1) Filter: (l_shipdate > '1995-03-04'::date) Rows Removed by Filter: 27404604 Buffers: shared hit=869694 read=197852 dirtied=1068 written=2 -> Hash (cost=533197.71..533197.71 rows=1455698 width=12) (actual time=8649.089..8649.089 rows=1449544 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78670kB Buffers: shared hit=289052 read=1154 -> Hash Join (cost=49763.50..533197.71 rows=1455698 width=12) (actual time=406.111..8118.129 rows=1449544 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=289052 read=1154 -> Seq Scan on orders (cost=0.00..441649.60 rows=7260701 width=16) (actual time=0.017..4203.191 rows=7227967 loops=1) Filter: (o_orderdate < '1995-03-04'::date) Rows Removed by Filter: 7787033 Buffers: shared hit=253775 -> Hash (cost=46004.31..46004.31 rows=300735 width=4) (actual time=401.165..401.165 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=35277 read=1154 -> Bitmap Heap Scan on customer (cost=6967.12..46004.31 rows=300735 width=4) (actual time=59.122..308.868 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=35277 read=1154 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6891.94 rows=300735 width=0) (actual time=51.750..51.750 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 5.134 ms Execution time: 30148.156 ms (38 rows) COMMIT; COMMIT