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 '1994-01-01' and l_shipdate < cast(date '1994-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1168068.21..1168068.22 rows=1 width=29) (actual time=8529.962..8529.963 rows=1 loops=1) Buffers: shared hit=311853 read=144168 dirtied=54 written=3687 -> Hash Join (cost=101765.71..1154629.66 rows=767917 width=29) (actual time=2467.930..8134.895 rows=771125 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=311853 read=144168 dirtied=54 written=3687 -> Bitmap Heap Scan on lineitem (cost=16243.71..1057588.90 rows=767917 width=12) (actual time=524.352..4871.484 rows=771125 loops=1) Recheck Cond: ((l_shipdate >= '1994-01-01'::date) AND (l_shipdate < '1994-02-01'::date)) Heap Blocks: exact=413385 Buffers: shared hit=278595 read=136901 dirtied=54 written=3149 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16051.74 rows=767917 width=0) (actual time=339.052..339.052 rows=775877 loops=1) Index Cond: ((l_shipdate >= '1994-01-01'::date) AND (l_shipdate < '1994-02-01'::date)) Buffers: shared hit=111 read=2000 written=83 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1917.278..1917.278 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=33255 read=7267 written=538 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..1014.577 rows=2000000 loops=1) Buffers: shared hit=33255 read=7267 written=538 Planning time: 2.973 ms Execution time: 8537.833 ms (19 rows) COMMIT; COMMIT