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 '1993-04-01' and l_shipdate < cast(date '1993-04-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Aggregate (cost=1150018.90..1150018.92 rows=1 width=29) (actual time=30879.481..30879.482 rows=1 loops=1) Buffers: shared hit=841817 read=266299 written=4489 -> Hash Join (cost=93390.87..1136836.94 rows=753255 width=29) (actual time=1633.485..30410.228 rows=749781 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=841817 read=266299 written=4489 -> Bitmap Heap Scan on lineitem (cost=7868.87..1040016.12 rows=753255 width=12) (actual time=119.205..27924.750 rows=749781 loops=1) Recheck Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Rows Removed by Index Recheck: 59295822 Heap Blocks: lossy=1067543 Buffers: shared hit=841808 read=225783 written=4489 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..7680.55 rows=753255 width=0) (actual time=118.420..118.420 rows=10676480 loops=1) Index Cond: ((l_shipdate >= '1993-04-01'::date) AND (l_shipdate < '1993-05-01'::date)) Buffers: shared hit=48 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1504.697..1504.697 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=6 read=40516 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.008..857.608 rows=2000000 loops=1) Buffers: shared hit=6 read=40516 Planning time: 2.456 ms Execution time: 30881.935 ms (20 rows) COMMIT; COMMIT