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-10-01' and l_shipdate < cast(date '1993-10-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1170513.06..1170513.07 rows=1 width=29) (actual time=6885.377..6885.377 rows=1 loops=1) Buffers: shared hit=237704 read=220007 written=104 -> Hash Join (cost=101765.35..1157054.65 rows=769052 width=29) (actual time=2076.015..6501.956 rows=773310 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=237704 read=220007 written=104 -> Bitmap Heap Scan on lineitem (cost=16243.35..1059996.87 rows=769052 width=12) (actual time=464.064..4204.070 rows=773310 loops=1) Recheck Cond: ((l_shipdate >= '1993-10-01'::date) AND (l_shipdate < '1993-11-01'::date)) Heap Blocks: exact=415071 Buffers: shared hit=235217 read=181969 written=48 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16051.09 rows=769052 width=0) (actual time=311.397..311.397 rows=779381 loops=1) Index Cond: ((l_shipdate >= '1993-10-01'::date) AND (l_shipdate < '1993-11-01'::date)) Buffers: shared read=2115 written=2 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1601.305..1601.305 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2484 read=38038 written=56 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..934.217 rows=2000000 loops=1) Buffers: shared hit=2484 read=38038 written=56 Planning time: 3.510 ms Execution time: 6888.401 ms (19 rows) COMMIT; COMMIT