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 '1993-07-01' and l_shipdate < cast(date '1993-07-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1172124.82..1172124.83 rows=1 width=29) (actual time=27348.029..27348.030 rows=1 loops=1) Buffers: shared hit=967529 read=152304 written=122 -> Hash Join (cost=93710.57..1158397.01 rows=784446 width=29) (actual time=1369.317..26874.729 rows=773357 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=967529 read=152304 written=122 -> Bitmap Heap Scan on lineitem (cost=8188.57..1061108.32 rows=784446 width=12) (actual time=124.095..24796.157 rows=773357 loops=1) Recheck Cond: ((l_shipdate >= '1993-07-01'::date) AND (l_shipdate < '1993-08-01'::date)) Rows Removed by Index Recheck: 59212181 Heap Blocks: lossy=1079260 Buffers: shared hit=927004 read=152304 written=122 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7992.46 rows=784446 width=0) (actual time=123.241..123.241 rows=10792960 loops=1) Index Cond: ((l_shipdate >= '1993-07-01'::date) AND (l_shipdate < '1993-08-01'::date)) Buffers: shared hit=48 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1238.958..1238.958 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40522 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.010..632.529 rows=2000000 loops=1) Buffers: shared hit=40522 Planning time: 2.540 ms Execution time: 27348.938 ms (20 rows) COMMIT; COMMIT