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 '1995-05-01' and l_shipdate < cast(date '1995-05-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1165843.98..1165843.99 rows=1 width=29) (actual time=6808.212..6808.213 rows=1 loops=1) Buffers: shared hit=286780 read=169573 dirtied=232 written=57 -> Hash Join (cost=101716.88..1152454.66 rows=765104 width=29) (actual time=2190.869..6417.339 rows=773568 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=286780 read=169573 dirtied=232 written=57 -> Bitmap Heap Scan on lineitem (cost=16194.88..1055456.10 rows=765104 width=12) (actual time=566.175..4107.140 rows=773568 loops=1) Recheck Cond: ((l_shipdate >= '1995-05-01'::date) AND (l_shipdate < '1995-06-01'::date)) Heap Blocks: exact=413712 Buffers: shared hit=285422 read=130406 dirtied=232 written=21 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16003.61 rows=765104 width=0) (actual time=379.646..379.646 rows=776652 loops=1) Index Cond: ((l_shipdate >= '1995-05-01'::date) AND (l_shipdate < '1995-06-01'::date)) Buffers: shared hit=2 read=2114 written=16 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1612.405..1612.405 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1355 read=39167 written=36 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.017..948.202 rows=2000000 loops=1) Buffers: shared hit=1355 read=39167 written=36 Planning time: 2.758 ms Execution time: 6814.481 ms (19 rows) COMMIT; COMMIT