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=2746390.94..2746390.97 rows=10 width=20) (actual time=85211.541..85211.546 rows=10 loops=1) Buffers: shared hit=960349 read=398725 -> Sort (cost=2746390.94..2754293.98 rows=3161217 width=20) (actual time=85211.538..85211.542 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=960349 read=398725 -> HashAggregate (cost=2646466.01..2678078.18 rows=3161217 width=20) (actual time=85088.397..85184.313 rows=114181 loops=1) Buffers: shared hit=960343 read=398725 -> Hash Join (cost=624689.28..2599047.75 rows=3161217 width=20) (actual time=28918.640..84534.398 rows=302494 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=960343 read=398725 -> Seq Scan on lineitem (cost=0.00..1820684.40 rows=32549841 width=12) (actual time=0.091..31763.184 rows=32515932 loops=1) Filter: (l_shipdate > '1995-03-09'::date) Rows Removed by Filter: 27529447 Buffers: shared hit=672900 read=395708 -> Hash (cost=606424.84..606424.84 rows=1461155 width=12) (actual time=28915.789..28915.789 rows=1455729 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62551kB Buffers: shared hit=287443 read=3017 -> Hash Join (cost=49808.54..606424.84 rows=1461155 width=12) (actual time=895.482..26665.971 rows=1455729 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=287443 read=3017 -> Seq Scan on orders (cost=0.00..442089.90 rows=7266535 width=16) (actual time=0.025..6634.417 rows=7259473 loops=1) Filter: (o_orderdate < '1995-03-09'::date) Rows Removed by Filter: 7755527 Buffers: shared hit=253104 read=924 -> Hash (cost=46038.29..46038.29 rows=301620 width=4) (actual time=895.073..895.073 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=34339 read=2093 -> Bitmap Heap Scan on customer (cost=6990.04..46038.29 rows=301620 width=4) (actual time=128.956..698.195 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=34339 read=2093 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6914.63 rows=301620 width=0) (actual time=115.060..115.060 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 85282.437 ms (35 rows) COMMIT; COMMIT