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-08-01' and l_shipdate < cast(date '1995-08-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1175238.59..1175238.60 rows=1 width=29) (actual time=9950.045..9950.045 rows=1 loops=1) Buffers: shared hit=211860 read=248062 written=114 -> Hash Join (cost=101818.26..1161710.34 rows=773043 width=29) (actual time=2633.445..9527.592 rows=773779 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=211860 read=248062 written=114 -> Bitmap Heap Scan on lineitem (cost=16296.26..1064592.69 rows=773043 width=12) (actual time=580.177..5983.398 rows=773779 loops=1) Recheck Cond: ((l_shipdate >= '1995-08-01'::date) AND (l_shipdate < '1995-09-01'::date)) Heap Blocks: exact=417281 Buffers: shared hit=211454 read=207943 written=102 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16103.00 rows=773043 width=0) (actual time=389.683..389.683 rows=783214 loops=1) Index Cond: ((l_shipdate >= '1995-08-01'::date) AND (l_shipdate < '1995-09-01'::date)) Buffers: shared read=2116 written=3 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=2040.461..2040.461 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=403 read=40119 written=12 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.018..1250.292 rows=2000000 loops=1) Buffers: shared hit=403 read=40119 written=12 Planning time: 3.476 ms Execution time: 9962.271 ms (19 rows) COMMIT; COMMIT