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-11-01' and l_shipdate < cast(date '1995-11-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1156058.41..1156058.43 rows=1 width=29) (actual time=7479.652..7479.652 rows=1 loops=1) Buffers: shared hit=85061 read=364684 written=58 -> Hash Join (cost=101211.07..1143075.11 rows=741903 width=29) (actual time=1922.298..7104.243 rows=748601 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=85061 read=364684 written=58 -> Bitmap Heap Scan on lineitem (cost=15689.07..1046424.56 rows=741903 width=12) (actual time=391.164..4907.997 rows=748601 loops=1) Recheck Cond: ((l_shipdate >= '1995-11-01'::date) AND (l_shipdate < '1995-12-01'::date)) Heap Blocks: exact=407173 Buffers: shared hit=85054 read=324166 written=58 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15503.59 rows=741903 width=0) (actual time=241.459..241.459 rows=753110 loops=1) Index Cond: ((l_shipdate >= '1995-11-01'::date) AND (l_shipdate < '1995-12-01'::date)) Buffers: shared read=2047 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1518.865..1518.865 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=4 read=40518 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..867.134 rows=2000000 loops=1) Buffers: shared hit=4 read=40518 Planning time: 2.775 ms Execution time: 7487.262 ms (19 rows) COMMIT; COMMIT