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 '1995-11-01' and l_shipdate < cast(date '1995-11-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1145389.35..1145389.36 rows=1 width=29) (actual time=27127.028..27127.029 rows=1 loops=1) Buffers: shared hit=572672 read=535444 written=6014 -> Hash Join (cost=93290.59..1132378.57 rows=743473 width=29) (actual time=1633.189..26670.451 rows=748601 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=572672 read=535444 written=6014 -> Bitmap Heap Scan on lineitem (cost=7768.59..1035704.47 rows=743473 width=12) (actual time=119.641..24322.912 rows=748601 loops=1) Recheck Cond: ((l_shipdate >= '1995-11-01'::date) AND (l_shipdate < '1995-12-01'::date)) Rows Removed by Index Recheck: 59297002 Heap Blocks: lossy=1067543 Buffers: shared hit=570745 read=496846 written=6014 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7582.73 rows=743473 width=0) (actual time=118.813..118.813 rows=10676480 loops=1) Index Cond: ((l_shipdate >= '1995-11-01'::date) AND (l_shipdate < '1995-12-01'::date)) Buffers: shared hit=48 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1503.602..1503.602 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1924 read=38598 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.013..851.437 rows=2000000 loops=1) Buffers: shared hit=1924 read=38598 Planning time: 2.082 ms Execution time: 27129.586 ms (20 rows) COMMIT; COMMIT