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 '1997-05-01' and l_shipdate < cast(date '1997-05-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1172970.18..1172970.19 rows=1 width=29) (actual time=7724.262..7724.262 rows=1 loops=1) Buffers: shared hit=304182 read=151843 dirtied=174 -> Hash Join (cost=102174.07..1159223.70 rows=785513 width=29) (actual time=2229.226..7321.544 rows=774552 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=304182 read=151843 dirtied=174 -> Bitmap Heap Scan on lineitem (cost=16652.07..1061919.01 rows=785513 width=12) (actual time=495.975..4641.708 rows=774552 loops=1) Recheck Cond: ((l_shipdate >= '1997-05-01'::date) AND (l_shipdate < '1997-06-01'::date)) Heap Blocks: exact=413382 Buffers: shared hit=263666 read=151834 dirtied=174 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16455.69 rows=785513 width=0) (actual time=339.548..339.548 rows=775346 loops=1) Index Cond: ((l_shipdate >= '1997-05-01'::date) AND (l_shipdate < '1997-06-01'::date)) Buffers: shared hit=2 read=2116 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1721.336..1721.336 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40513 read=9 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.018..747.537 rows=2000000 loops=1) Buffers: shared hit=40513 read=9 Planning time: 2.993 ms Execution time: 7730.878 ms (19 rows) COMMIT; COMMIT