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-04-01' and l_shipdate < cast(date '1995-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1160259.44..1160259.45 rows=1 width=29) (actual time=41812.724..41812.724 rows=1 loops=1) Buffers: shared hit=185 read=1106861 dirtied=1069 written=41661 -> Hash Join (cost=93638.72..1146654.29 rows=777437 width=29) (actual time=1542.108..41264.028 rows=751371 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=185 read=1106861 dirtied=1069 written=41661 -> Bitmap Heap Scan on lineitem (cost=8116.72..1049470.73 rows=777437 width=12) (actual time=118.408..38815.337 rows=751371 loops=1) Recheck Cond: ((l_shipdate >= '1995-04-01'::date) AND (l_shipdate < '1995-05-01'::date)) Rows Removed by Index Recheck: 59294298 Heap Blocks: lossy=1066473 Buffers: shared hit=180 read=1066341 dirtied=1069 written=41661 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7922.37 rows=777437 width=0) (actual time=117.600..117.600 rows=10664960 loops=1) Index Cond: ((l_shipdate >= '1995-04-01'::date) AND (l_shipdate < '1995-05-01'::date)) Buffers: shared hit=48 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1417.735..1417.735 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2 read=40520 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.005..794.758 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 Planning time: 3.197 ms Execution time: 41813.587 ms (20 rows) COMMIT; COMMIT