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 '1994-04-01' and l_shipdate < cast(date '1994-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1179674.47..1179674.48 rows=1 width=29) (actual time=8085.218..8085.219 rows=1 loops=1) Buffers: shared hit=215260 read=236528 written=119 -> Hash Join (cost=102065.47..1165949.52 rows=784283 width=29) (actual time=2490.201..7692.653 rows=747587 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=215260 read=236528 written=119 -> Bitmap Heap Scan on lineitem (cost=16543.47..1068663.27 rows=784283 width=12) (actual time=713.397..5159.638 rows=747587 loops=1) Recheck Cond: ((l_shipdate >= '1994-04-01'::date) AND (l_shipdate < '1994-05-01'::date)) Heap Blocks: exact=409218 Buffers: shared hit=213274 read=197989 written=80 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16347.40 rows=784283 width=0) (actual time=541.893..541.893 rows=755762 loops=1) Index Cond: ((l_shipdate >= '1994-04-01'::date) AND (l_shipdate < '1994-05-01'::date)) Buffers: shared hit=2 read=2043 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1762.382..1762.382 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1983 read=38539 written=39 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.020..1043.896 rows=2000000 loops=1) Buffers: shared hit=1983 read=38539 written=39 Planning time: 4.516 ms Execution time: 8090.919 ms (19 rows) COMMIT; COMMIT