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 '1993-04-01' and l_shipdate < cast(date '1993-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1153783.68..1153783.70 rows=1 width=29) (actual time=6998.230..6998.230 rows=1 loops=1) Buffers: shared hit=311118 read=137300 dirtied=193 written=2114 -> Hash Join (cost=101312.63..1140749.91 rows=744787 width=29) (actual time=2212.041..6610.513 rows=749071 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=311118 read=137300 dirtied=193 written=2114 -> Bitmap Heap Scan on lineitem (cost=15790.63..1044056.10 rows=744787 width=12) (actual time=487.337..4178.000 rows=749071 loops=1) Recheck Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Heap Blocks: exact=405842 Buffers: shared hit=280202 read=127691 dirtied=193 written=1719 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15604.43 rows=744787 width=0) (actual time=333.046..333.046 rows=750270 loops=1) Index Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Buffers: shared hit=101 read=1950 written=69 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1713.118..1713.118 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=30913 read=9609 written=395 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.020..998.941 rows=2000000 loops=1) Buffers: shared hit=30913 read=9609 written=395 Planning time: 2.920 ms Execution time: 7001.772 ms (19 rows) COMMIT; COMMIT