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 '1996-12-01' and l_shipdate < cast(date '1996-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1172016.48..1172016.50 rows=1 width=29) (actual time=8529.239..8529.239 rows=1 loops=1) Buffers: shared hit=201015 read=257871 written=181 -> Hash Join (cost=101794.65..1158528.53 rows=770740 width=29) (actual time=2781.960..8103.648 rows=773334 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=201015 read=257871 written=181 -> Bitmap Heap Scan on lineitem (cost=16272.65..1061445.43 rows=770740 width=12) (actual time=941.003..5439.732 rows=773334 loops=1) Recheck Cond: ((l_shipdate >= '1996-12-01'::date) AND (l_shipdate < '1997-01-01'::date)) Heap Blocks: exact=416245 Buffers: shared hit=200277 read=218084 written=145 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16079.97 rows=770740 width=0) (actual time=607.310..607.310 rows=780256 loops=1) Index Cond: ((l_shipdate >= '1996-12-01'::date) AND (l_shipdate < '1997-01-01'::date)) Buffers: shared read=2116 written=2 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1828.338..1828.338 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=735 read=39787 written=36 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..1057.174 rows=2000000 loops=1) Buffers: shared hit=735 read=39787 written=36 Planning time: 4.928 ms Execution time: 8535.991 ms (19 rows) COMMIT; COMMIT