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-09-01' and l_shipdate < cast(date '1997-09-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1152574.27..1152574.29 rows=1 width=29) (actual time=20248.869..20248.869 rows=1 loops=1) Buffers: shared hit=1096849 read=22984 dirtied=1061 written=1 -> Hash Join (cost=93280.17..1139581.29 rows=742456 width=29) (actual time=1443.402..19875.844 rows=748402 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=1096849 read=22984 dirtied=1061 written=1 -> Bitmap Heap Scan on lineitem (cost=7758.17..1042922.45 rows=742456 width=12) (actual time=124.441..17852.247 rows=748402 loops=1) Recheck Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Rows Removed by Index Recheck: 59237136 Heap Blocks: lossy=1079260 Buffers: shared hit=1056327 read=22981 dirtied=1061 written=1 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7572.56 rows=742456 width=0) (actual time=123.619..123.619 rows=10792960 loops=1) Index Cond: ((l_shipdate >= '1997-09-01'::date) AND (l_shipdate < '1997-10-01'::date)) Buffers: shared hit=23 read=25 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1312.684..1312.684 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=40519 read=3 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.009..624.854 rows=2000000 loops=1) Buffers: shared hit=40519 read=3 Planning time: 2.535 ms Execution time: 20249.999 ms (20 rows) COMMIT; COMMIT