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-12-01' and l_shipdate < cast(date '1997-12-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1164124.44..1164124.45 rows=1 width=29) (actual time=23275.381..23275.381 rows=1 loops=1) Buffers: shared hit=573220 read=544470 dirtied=973 written=9224 -> Hash Join (cost=93561.28..1150651.52 rows=769881 width=29) (actual time=1350.513..22830.232 rows=772832 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=573220 read=544470 dirtied=973 written=9224 -> Bitmap Heap Scan on lineitem (cost=8039.28..1053581.30 rows=769881 width=12) (actual time=121.028..20863.532 rows=772832 loops=1) Recheck Cond: ((l_shipdate >= '1997-12-01'::date) AND (l_shipdate < '1998-01-01'::date)) Rows Removed by Index Recheck: 59272040 Heap Blocks: lossy=1077117 Buffers: shared hit=532699 read=544466 dirtied=973 written=9224 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7846.81 rows=769881 width=0) (actual time=120.208..120.208 rows=10771200 loops=1) Index Cond: ((l_shipdate >= '1997-12-01'::date) AND (l_shipdate < '1998-01-01'::date)) Buffers: shared hit=16 read=32 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1223.227..1223.227 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40518 read=4 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.010..619.509 rows=2000000 loops=1) Buffers: shared hit=40518 read=4 Planning time: 2.238 ms Execution time: 23276.262 ms (20 rows) COMMIT; COMMIT