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-08-01' and l_shipdate < cast(date '1996-08-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1159334.56..1159334.58 rows=1 width=29) (actual time=25456.856..25456.857 rows=1 loops=1) Buffers: shared hit=567530 read=545376 written=6941 -> Hash Join (cost=93526.23..1145921.50 rows=766461 width=29) (actual time=1825.065..25002.196 rows=772370 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=567530 read=545376 written=6941 -> Bitmap Heap Scan on lineitem (cost=8004.23..1048902.58 rows=766461 width=12) (actual time=127.132..22432.196 rows=772370 loops=1) Recheck Cond: ((l_shipdate >= '1996-08-01'::date) AND (l_shipdate < '1996-09-01'::date)) Rows Removed by Index Recheck: 59213317 Heap Blocks: lossy=1072333 Buffers: shared hit=567525 read=504856 written=4864 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7812.61 rows=766461 width=0) (actual time=126.169..126.169 rows=10723840 loops=1) Index Cond: ((l_shipdate >= '1996-08-01'::date) AND (l_shipdate < '1996-09-01'::date)) Buffers: shared hit=13 read=35 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1688.852..1688.852 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=2 read=40520 written=2077 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.012..967.036 rows=2000000 loops=1) Buffers: shared hit=2 read=40520 written=2077 Planning time: 2.392 ms Execution time: 25458.052 ms (20 rows) COMMIT; COMMIT