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=1183952.26..1183952.27 rows=1 width=29) (actual time=8338.891..8338.891 rows=1 loops=1) Buffers: shared hit=224294 read=233005 dirtied=567 written=44 -> Hash Join (cost=102531.88..1169881.72 rows=804031 width=29) (actual time=2164.783..7923.733 rows=773985 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=224294 read=233005 dirtied=567 written=44 -> Bitmap Heap Scan on lineitem (cost=17009.88..1072299.25 rows=804031 width=12) (actual time=604.447..5265.498 rows=773985 loops=1) Recheck Cond: ((l_shipdate >= '1993-07-01'::date) AND (l_shipdate < '1993-08-01'::date)) Heap Blocks: exact=414657 Buffers: shared hit=198848 read=217926 dirtied=567 written=44 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16808.88 rows=804031 width=0) (actual time=420.075..420.075 rows=777890 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=1547.292..1547.292 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=25443 read=15079 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.011..831.622 rows=2000000 loops=1) Buffers: shared hit=25443 read=15079 Planning time: 4.630 ms Execution time: 8346.972 ms (19 rows) COMMIT; COMMIT