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 '1993-03-01' and l_shipdate < cast(date '1993-03-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1182926.07..1182926.08 rows=1 width=29) (actual time=21014.204..21014.204 rows=1 loops=1) Buffers: shared hit=323370 read=134882 -> Hash Join (cost=102158.02..1169163.05 rows=786458 width=29) (actual time=3405.031..20294.712 rows=775107 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=323370 read=134882 -> Bitmap Heap Scan on lineitem (cost=16636.02..1065945.75 rows=786458 width=12) (actual time=926.333..14611.706 rows=775107 loops=1) Recheck Cond: ((l_shipdate >= '1993-03-01'::date) AND (l_shipdate < '1993-04-01'::date)) Buffers: shared hit=285607 read=132120 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16439.41 rows=786458 width=0) (actual time=721.822..721.822 rows=779610 loops=1) Index Cond: ((l_shipdate >= '1993-03-01'::date) AND (l_shipdate < '1993-04-01'::date)) Buffers: shared hit=2 read=2118 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2476.544..2476.544 rows=2000000 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 115519kB Buffers: shared hit=37760 read=2762 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.017..1462.652 rows=2000000 loops=1) Buffers: shared hit=37760 read=2762 Total runtime: 21030.511 ms (17 rows) COMMIT; COMMIT