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-03-01' and l_shipdate < cast(date '1995-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1179593.38..1179593.40 rows=1 width=29) (actual time=7720.784..7720.784 rows=1 loops=1) Buffers: shared hit=164366 read=294548 dirtied=376 written=171 -> Hash Join (cost=102144.85..1165814.84 rows=787345 width=29) (actual time=2198.598..7326.756 rows=775040 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=164366 read=294548 dirtied=376 written=171 -> Bitmap Heap Scan on lineitem (cost=16622.85..1068482.67 rows=787345 width=12) (actual time=569.143..4951.978 rows=775040 loops=1) Recheck Cond: ((l_shipdate >= '1995-03-01'::date) AND (l_shipdate < '1995-04-01'::date)) Heap Blocks: exact=416269 Buffers: shared hit=162279 read=256110 dirtied=376 written=168 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16426.01 rows=787345 width=0) (actual time=371.384..371.384 rows=782128 loops=1) Index Cond: ((l_shipdate >= '1995-03-01'::date) AND (l_shipdate < '1995-04-01'::date)) Buffers: shared read=2120 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1617.043..1617.043 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2084 read=38438 written=3 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.016..926.746 rows=2000000 loops=1) Buffers: shared hit=2084 read=38438 written=3 Planning time: 2.529 ms Execution time: 7725.597 ms (19 rows) COMMIT; COMMIT