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-08-01' and l_shipdate < cast(date '1997-08-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1156656.13..1156656.14 rows=1 width=29) (actual time=8784.873..8784.873 rows=1 loops=1) Buffers: shared hit=245956 read=211999 dirtied=426 written=265 -> Hash Join (cost=101159.24..1143699.85 rows=740359 width=29) (actual time=3077.665..8340.361 rows=772354 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=245956 read=211999 dirtied=426 written=265 -> Bitmap Heap Scan on lineitem (cost=15637.24..1047072.46 rows=740359 width=12) (actual time=916.007..5332.577 rows=772354 loops=1) Recheck Cond: ((l_shipdate >= '1997-08-01'::date) AND (l_shipdate < '1997-09-01'::date)) Heap Blocks: exact=415317 Buffers: shared hit=213656 read=203774 dirtied=426 written=261 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15452.16 rows=740359 width=0) (actual time=579.370..579.370 rows=778639 loops=1) Index Cond: ((l_shipdate >= '1997-08-01'::date) AND (l_shipdate < '1997-09-01'::date)) Buffers: shared hit=3 read=2110 written=14 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2146.019..2146.019 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=32297 read=8225 written=4 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.022..1154.748 rows=2000000 loops=1) Buffers: shared hit=32297 read=8225 written=4 Planning time: 4.038 ms Execution time: 8792.276 ms (19 rows) COMMIT; COMMIT