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 '1997-06-01' and l_shipdate < cast(date '1997-06-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1146942.45..1146942.47 rows=1 width=29) (actual time=25849.847..25849.847 rows=1 loops=1) Buffers: shared hit=635464 read=479024 written=3786 -> Hash Join (cost=93235.21..1134026.24 rows=738069 width=29) (actual time=1674.048..25403.248 rows=748947 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=635464 read=479024 written=3786 -> Bitmap Heap Scan on lineitem (cost=7713.21..1037433.21 rows=738069 width=12) (actual time=120.468..23080.257 rows=748947 loops=1) Recheck Cond: ((l_shipdate >= '1997-06-01'::date) AND (l_shipdate < '1997-07-01'::date)) Rows Removed by Index Recheck: 59295717 Heap Blocks: lossy=1073915 Buffers: shared hit=632542 read=441421 written=3740 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7528.69 rows=738069 width=0) (actual time=119.669..119.669 rows=10739200 loops=1) Index Cond: ((l_shipdate >= '1997-06-01'::date) AND (l_shipdate < '1997-07-01'::date)) Buffers: shared hit=13 read=35 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1547.383..1547.383 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2919 read=37603 written=46 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.008..910.884 rows=2000000 loops=1) Buffers: shared hit=2919 read=37603 written=46 Planning time: 2.930 ms Execution time: 25850.735 ms (20 rows) COMMIT; COMMIT