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-12-01' and l_shipdate < cast(date '1996-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1166687.35..1166687.36 rows=1 width=29) (actual time=26754.270..26754.271 rows=1 loops=1) Buffers: shared hit=675973 read=443860 written=160 -> Hash Join (cost=93586.36..1153171.61 rows=772328 width=29) (actual time=1358.010..26285.417 rows=772430 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=675973 read=443860 written=160 -> Bitmap Heap Scan on lineitem (cost=8064.36..1056064.69 rows=772328 width=12) (actual time=121.379..24214.310 rows=772430 loops=1) Recheck Cond: ((l_shipdate >= '1996-12-01'::date) AND (l_shipdate < '1997-01-01'::date)) Rows Removed by Index Recheck: 59213108 Heap Blocks: lossy=1079260 Buffers: shared hit=635448 read=443860 written=160 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7871.28 rows=772328 width=0) (actual time=120.605..120.605 rows=10792960 loops=1) Index Cond: ((l_shipdate >= '1996-12-01'::date) AND (l_shipdate < '1997-01-01'::date)) Buffers: shared hit=48 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1230.392..1230.392 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.009..626.223 rows=2000000 loops=1) Buffers: shared hit=40522 Planning time: 2.292 ms Execution time: 26755.169 ms (20 rows) COMMIT; COMMIT