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-01-01' and l_shipdate < cast(date '1993-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1169473.07..1169473.09 rows=1 width=29) (actual time=7130.516..7130.516 rows=1 loops=1) Buffers: shared hit=220776 read=234842 dirtied=160 -> Hash Join (cost=102009.80..1155863.65 rows=777681 width=29) (actual time=2090.012..6747.972 rows=773998 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=220776 read=234842 dirtied=160 -> Bitmap Heap Scan on lineitem (cost=16487.80..1058676.44 rows=777681 width=12) (actual time=492.455..4347.690 rows=773998 loops=1) Recheck Cond: ((l_shipdate >= '1993-01-01'::date) AND (l_shipdate < '1993-02-01'::date)) Heap Blocks: exact=412976 Buffers: shared hit=219098 read=195995 dirtied=160 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16293.38 rows=777681 width=0) (actual time=324.553..324.553 rows=774742 loops=1) Index Cond: ((l_shipdate >= '1993-01-01'::date) AND (l_shipdate < '1993-02-01'::date)) Buffers: shared hit=1 read=2116 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1581.246..1581.246 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1675 read=38847 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.015..909.019 rows=2000000 loops=1) Buffers: shared hit=1675 read=38847 Planning time: 2.675 ms Execution time: 7139.603 ms (19 rows) COMMIT; COMMIT