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 '1997-12-01' and l_shipdate < cast(date '1997-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1173300.46..1173300.47 rows=1 width=29) (actual time=7097.897..7097.897 rows=1 loops=1) Buffers: shared hit=226425 read=232411 written=40 -> Hash Join (cost=101771.43..1159818.00 rows=770426 width=29) (actual time=1965.270..6706.814 rows=772864 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=226425 read=232411 written=40 -> Bitmap Heap Scan on lineitem (cost=16249.43..1062739.61 rows=770426 width=12) (actual time=614.378..4604.869 rows=772864 loops=1) Recheck Cond: ((l_shipdate >= '1997-12-01'::date) AND (l_shipdate < '1998-01-01'::date)) Heap Blocks: exact=416198 Buffers: shared hit=185908 read=232403 written=40 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16056.83 rows=770426 width=0) (actual time=412.095..412.095 rows=781171 loops=1) Index Cond: ((l_shipdate >= '1997-12-01'::date) AND (l_shipdate < '1998-01-01'::date)) Buffers: shared read=2113 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1339.677..1339.677 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40514 read=8 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.016..657.369 rows=2000000 loops=1) Buffers: shared hit=40514 read=8 Planning time: 3.003 ms Execution time: 7101.818 ms (19 rows) COMMIT; COMMIT