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-08-01' and l_shipdate < cast(date '1996-08-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1170427.67..1170427.69 rows=1 width=29) (actual time=9358.070..9358.071 rows=1 loops=1) Buffers: shared hit=231473 read=224339 dirtied=458 written=8155 -> Hash Join (cost=101958.58..1156844.23 rows=776197 width=29) (actual time=2786.165..8921.289 rows=772326 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=231473 read=224339 dirtied=458 written=8155 -> Bitmap Heap Scan on lineitem (cost=16436.58..1059679.27 rows=776197 width=12) (actual time=673.447..5428.332 rows=772326 loops=1) Recheck Cond: ((l_shipdate >= '1996-08-01'::date) AND (l_shipdate < '1996-09-01'::date)) Heap Blocks: exact=413172 Buffers: shared hit=231468 read=183819 dirtied=458 written=6273 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16242.54 rows=776197 width=0) (actual time=432.657..432.657 rows=775610 loops=1) Index Cond: ((l_shipdate >= '1996-08-01'::date) AND (l_shipdate < '1996-09-01'::date)) Buffers: shared hit=117 read=1998 written=104 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2088.300..2088.300 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2 read=40520 written=1882 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.010..1122.238 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 written=1882 Planning time: 4.518 ms Execution time: 9367.318 ms (19 rows) COMMIT; COMMIT