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-07-01' and l_shipdate < cast(date '1996-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1186653.19..1186653.20 rows=1 width=29) (actual time=19174.689..19174.689 rows=1 loops=1) Buffers: shared hit=164324 read=293763 written=58 -> Hash Join (cost=102205.08..1172830.32 rows=789878 width=29) (actual time=3917.747..18461.344 rows=772783 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=164324 read=293763 written=58 -> Bitmap Heap Scan on lineitem (cost=16683.08..1069536.07 rows=789878 width=12) (actual time=957.439..12544.077 rows=772783 loops=1) Recheck Cond: ((l_shipdate >= '1996-07-01'::date) AND (l_shipdate < '1996-08-01'::date)) Buffers: shared hit=151886 read=265676 written=58 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16485.61 rows=789878 width=0) (actual time=699.440..699.440 rows=779536 loops=1) Index Cond: ((l_shipdate >= '1996-07-01'::date) AND (l_shipdate < '1996-08-01'::date)) Buffers: shared hit=292 read=1821 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2958.073..2958.073 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=12435 read=28087 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..1829.743 rows=2000000 loops=1) Buffers: shared hit=12435 read=28087 Total runtime: 19190.715 ms (17 rows) COMMIT; COMMIT