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-02-01' and l_shipdate < cast(date '1996-02-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1147192.09..1147192.11 rows=1 width=29) (actual time=24814.744..24814.744 rows=1 loops=1) Buffers: shared hit=845477 read=269011 written=4778 -> Hash Join (cost=93240.42..1134266.99 rows=738577 width=29) (actual time=1698.237..24394.292 rows=722599 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=845477 read=269011 written=4778 -> Bitmap Heap Scan on lineitem (cost=7718.42..1037666.34 rows=738577 width=12) (actual time=119.898..22042.502 rows=722599 loops=1) Recheck Cond: ((l_shipdate >= '1996-02-01'::date) AND (l_shipdate < '1996-03-01'::date)) Rows Removed by Index Recheck: 59322065 Heap Blocks: lossy=1073915 Buffers: shared hit=842063 read=231900 written=476 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7533.77 rows=738577 width=0) (actual time=119.152..119.152 rows=10739200 loops=1) Index Cond: ((l_shipdate >= '1996-02-01'::date) AND (l_shipdate < '1996-03-01'::date)) Buffers: shared hit=48 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1572.130..1572.130 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=3411 read=37111 written=4302 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.008..949.842 rows=2000000 loops=1) Buffers: shared hit=3411 read=37111 written=4302 Planning time: 2.393 ms Execution time: 24815.609 ms (20 rows) COMMIT; COMMIT