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-07-01' and l_shipdate < cast(date '1997-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1190343.29..1190343.30 rows=1 width=29) (actual time=6122.023..6122.023 rows=1 loops=1) Buffers: shared hit=360627 read=95098 dirtied=176 written=14 -> Hash Join (cost=103049.04..1175874.67 rows=826778 width=29) (actual time=1899.658..5734.518 rows=774574 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=360627 read=95098 dirtied=176 written=14 -> Bitmap Heap Scan on lineitem (cost=17527.04..1077951.00 rows=826778 width=12) (actual time=494.028..3631.959 rows=774574 loops=1) Recheck Cond: ((l_shipdate >= '1997-07-01'::date) AND (l_shipdate < '1997-08-01'::date)) Heap Blocks: exact=413082 Buffers: shared hit=320102 read=95098 dirtied=176 written=14 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..17320.34 rows=826778 width=0) (actual time=338.633..338.633 rows=775339 loops=1) Index Cond: ((l_shipdate >= '1997-07-01'::date) AND (l_shipdate < '1997-08-01'::date)) Buffers: shared hit=2 read=2116 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1394.279..1394.279 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40522 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..728.657 rows=2000000 loops=1) Buffers: shared hit=40522 Planning time: 2.923 ms Execution time: 6124.656 ms (19 rows) COMMIT; COMMIT