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-04-01' and l_shipdate < cast(date '1997-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1167187.90..1167187.92 rows=1 width=29) (actual time=13157.427..13157.427 rows=1 loops=1) Buffers: shared hit=315019 read=139623 written=98 -> Hash Join (cost=101154.59..1154202.46 rows=742025 width=29) (actual time=3768.933..12560.299 rows=751150 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=315019 read=139623 written=98 -> Bitmap Heap Scan on lineitem (cost=15632.59..1051984.90 rows=742025 width=12) (actual time=866.454..6234.595 rows=751150 loops=1) Recheck Cond: ((l_shipdate >= '1997-04-01'::date) AND (l_shipdate < '1997-05-01'::date)) Buffers: shared hit=315014 read=99103 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15447.08 rows=742025 width=0) (actual time=649.903..649.903 rows=761325 loops=1) Index Cond: ((l_shipdate >= '1997-04-01'::date) AND (l_shipdate < '1997-05-01'::date)) Buffers: shared hit=2 read=2052 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2900.354..2900.354 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=2 read=40520 written=98 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.011..1701.510 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 written=98 Total runtime: 13198.213 ms (17 rows) COMMIT; COMMIT