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-07-01' and l_shipdate < cast(date '1993-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1170448.12..1170448.14 rows=1 width=29) (actual time=6391.137..6391.137 rows=1 loops=1) Buffers: shared hit=166220 read=290648 -> Hash Join (cost=101927.04..1156884.38 rows=775071 width=29) (actual time=1842.318..6023.952 rows=773182 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=166220 read=290648 -> Bitmap Heap Scan on lineitem (cost=16405.04..1059736.32 rows=775071 width=12) (actual time=420.701..3969.515 rows=773182 loops=1) Recheck Cond: ((l_shipdate >= '1993-07-01'::date) AND (l_shipdate < '1993-08-01'::date)) Heap Blocks: exact=414226 Buffers: shared hit=162765 read=253578 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16211.27 rows=775071 width=0) (actual time=266.289..266.289 rows=777087 loops=1) Index Cond: ((l_shipdate >= '1993-07-01'::date) AND (l_shipdate < '1993-08-01'::date)) Buffers: shared read=2117 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1410.224..1410.224 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=3452 read=37070 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.018..795.004 rows=2000000 loops=1) Buffers: shared hit=3452 read=37070 Planning time: 2.513 ms Execution time: 6397.585 ms (19 rows) COMMIT; COMMIT