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-03' and l_shipdate > date '1995-03-03' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2672254.79..2672254.82 rows=10 width=20) (actual time=33670.575..33670.578 rows=10 loops=1) Buffers: shared hit=797692 read=560066 dirtied=1010 written=1028 -> Sort (cost=2672254.79..2680175.70 rows=3168361 width=20) (actual time=33670.572..33670.574 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=797692 read=560066 dirtied=1010 written=1028 -> HashAggregate (cost=2572104.04..2603787.65 rows=3168361 width=20) (actual time=33589.478..33651.486 rows=114092 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=797686 read=560066 dirtied=1010 written=1028 -> Hash Join (cost=551401.10..2524578.63 rows=3168361 width=20) (actual time=9501.626..33266.627 rows=301900 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=797686 read=560066 dirtied=1010 written=1028 -> Seq Scan on lineitem (cost=0.00..1818865.35 rows=32700952 width=12) (actual time=0.033..17013.537 rows=32666207 loops=1) Filter: (l_shipdate > '1995-03-03'::date) Rows Removed by Filter: 27379396 Buffers: shared hit=551836 read=515710 dirtied=1010 written=997 -> Hash (cost=533198.12..533198.12 rows=1456238 width=12) (actual time=9447.971..9447.971 rows=1448266 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78615kB Buffers: shared hit=245850 read=44356 written=31 -> Hash Join (cost=49784.60..533198.12 rows=1456238 width=12) (actual time=728.018..8892.128 rows=1448266 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=245850 read=44356 written=31 -> Seq Scan on orders (cost=0.00..441649.60 rows=7253745 width=16) (actual time=0.043..4342.167 rows=7221694 loops=1) Filter: (o_orderdate < '1995-03-03'::date) Rows Removed by Filter: 7793306 Buffers: shared hit=245848 read=7927 -> Hash (cost=46020.41..46020.41 rows=301135 width=4) (actual time=723.217..723.217 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=2 read=36429 written=31 -> Bitmap Heap Scan on customer (cost=6978.22..46020.41 rows=301135 width=4) (actual time=64.549..613.811 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=2 read=36429 written=31 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6902.94 rows=301135 width=0) (actual time=56.704..56.704 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 3.259 ms Execution time: 33702.019 ms (38 rows) COMMIT; COMMIT