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-01-01' and l_shipdate < cast(date '1996-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1168501.23..1168501.24 rows=1 width=29) (actual time=27229.861..27229.861 rows=1 loops=1) Buffers: shared hit=186544 read=268446 -> Hash Join (cost=101706.47..1155147.21 rows=763087 width=29) (actual time=5308.420..26547.435 rows=772594 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=186544 read=268446 -> Bitmap Heap Scan on lineitem (cost=16184.47..1052455.75 rows=763087 width=12) (actual time=976.226..18332.929 rows=772594 loops=1) Recheck Cond: ((l_shipdate >= '1996-01-01'::date) AND (l_shipdate < '1996-02-01'::date)) Buffers: shared hit=169849 read=244616 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15993.70 rows=763087 width=0) (actual time=684.736..684.736 rows=773370 loops=1) Index Cond: ((l_shipdate >= '1996-01-01'::date) AND (l_shipdate < '1996-02-01'::date)) Buffers: shared hit=1 read=2113 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=4328.887..4328.887 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=16692 read=23830 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.022..3129.362 rows=2000000 loops=1) Buffers: shared hit=16692 read=23830 Total runtime: 27262.829 ms (17 rows) COMMIT; COMMIT