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-09-01' and l_shipdate < cast(date '1994-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1177593.07..1177593.08 rows=1 width=29) (actual time=7639.413..7639.413 rows=1 loops=1) Buffers: shared hit=222425 read=229183 dirtied=163 written=468 -> Hash Join (cost=102091.82..1163864.09 rows=784513 width=29) (actual time=2313.960..7253.018 rows=750479 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=222425 read=229183 dirtied=163 written=468 -> Bitmap Heap Scan on lineitem (cost=16569.82..1066574.40 rows=784513 width=12) (actual time=547.306..4431.130 rows=750479 loops=1) Recheck Cond: ((l_shipdate >= '1994-09-01'::date) AND (l_shipdate < '1994-10-01'::date)) Heap Blocks: exact=409030 Buffers: shared hit=216527 read=194556 dirtied=163 written=408 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16373.70 rows=784513 width=0) (actual time=362.276..362.276 rows=756787 loops=1) Index Cond: ((l_shipdate >= '1994-09-01'::date) AND (l_shipdate < '1994-10-01'::date)) Buffers: shared read=2053 written=4 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1749.751..1749.751 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=5895 read=34627 written=60 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.011..917.142 rows=2000000 loops=1) Buffers: shared hit=5895 read=34627 written=60 Planning time: 3.642 ms Execution time: 7646.318 ms (19 rows) COMMIT; COMMIT