BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= date '1996-09-01' and l_shipdate < cast(date '1996-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1177524.34..1177524.36 rows=1 width=29) (actual time=12421.893..12421.894 rows=1 loops=1) Buffers: shared hit=267037 read=186482 dirtied=834 written=108 -> Hash Join (cost=101630.07..1164150.51 rows=764219 width=29) (actual time=3548.046..11862.227 rows=750330 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=267037 read=186482 dirtied=834 written=108 -> Bitmap Heap Scan on lineitem (cost=16108.07..1061433.58 rows=764219 width=12) (actual time=915.432..6425.939 rows=750330 loops=1) Recheck Cond: ((l_shipdate >= '1996-09-01'::date) AND (l_shipdate < '1996-10-01'::date)) Buffers: shared hit=254309 read=158685 dirtied=834 written=108 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15917.02 rows=764219 width=0) (actual time=503.917..503.917 rows=760104 loops=1) Index Cond: ((l_shipdate >= '1996-09-01'::date) AND (l_shipdate < '1996-10-01'::date)) Buffers: shared read=2053 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2630.073..2630.073 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=12725 read=27797 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.027..1470.561 rows=2000000 loops=1) Buffers: shared hit=12725 read=27797 Total runtime: 12440.210 ms (17 rows) COMMIT; COMMIT