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-08-01' and l_shipdate < cast(date '1995-08-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1170919.53..1170919.55 rows=1 width=29) (actual time=6579.025..6579.025 rows=1 loops=1) Buffers: shared hit=241143 read=217131 -> Hash Join (cost=101786.23..1157445.95 rows=769919 width=29) (actual time=1891.571..6216.025 rows=773101 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=241143 read=217131 -> Bitmap Heap Scan on lineitem (cost=16264.23..1060375.17 rows=769919 width=12) (actual time=402.798..4067.016 rows=773101 loops=1) Recheck Cond: ((l_shipdate >= '1995-08-01'::date) AND (l_shipdate < '1995-09-01'::date)) Heap Blocks: exact=415633 Buffers: shared hit=228679 read=189070 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16071.76 rows=769919 width=0) (actual time=263.869..263.869 rows=780185 loops=1) Index Cond: ((l_shipdate >= '1995-08-01'::date) AND (l_shipdate < '1995-09-01'::date)) Buffers: shared read=2116 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1477.359..1477.359 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=12461 read=28061 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.014..828.127 rows=2000000 loops=1) Buffers: shared hit=12461 read=28061 Planning time: 2.308 ms Execution time: 6582.852 ms (19 rows) COMMIT; COMMIT