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 '1995-09-01' and l_shipdate < cast(date '1995-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1177106.41..1177106.42 rows=1 width=29) (actual time=16479.757..16479.757 rows=1 loops=1) Buffers: shared hit=126600 read=327733 written=156 -> Hash Join (cost=101574.42..1163772.97 rows=761911 width=29) (actual time=3803.717..15791.703 rows=749681 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=126600 read=327733 written=156 -> Bitmap Heap Scan on lineitem (cost=16052.42..1061107.97 rows=761911 width=12) (actual time=1047.985..9343.518 rows=749681 loops=1) Recheck Cond: ((l_shipdate >= '1995-09-01'::date) AND (l_shipdate < '1995-10-01'::date)) Buffers: shared hit=126590 read=287218 written=118 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15861.94 rows=761911 width=0) (actual time=678.864..678.864 rows=760393 loops=1) Index Cond: ((l_shipdate >= '1995-09-01'::date) AND (l_shipdate < '1995-10-01'::date)) Buffers: shared hit=2 read=2050 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2753.501..2753.501 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=7 read=40515 written=38 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..1431.429 rows=2000000 loops=1) Buffers: shared hit=7 read=40515 written=38 Total runtime: 16507.182 ms (17 rows) COMMIT; COMMIT