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 '1994-04-01' and l_shipdate < cast(date '1994-04-01' + interval '1 month' as date); QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1153210.59..1153210.60 rows=1 width=29) (actual time=7486.605..7486.605 rows=1 loops=1) Buffers: shared hit=212890 read=234928 dirtied=133 written=494 -> Hash Join (cost=101275.54..1140205.99 rows=743120 width=29) (actual time=2881.119..7129.371 rows=747539 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=212890 read=234928 dirtied=133 written=494 -> Bitmap Heap Scan on lineitem (cost=15753.55..1043537.19 rows=743120 width=12) (actual time=1347.498..4843.715 rows=747539 loops=1) Recheck Cond: ((l_shipdate >= '1994-04-01'::date) AND (l_shipdate < '1994-05-01'::date)) Heap Blocks: exact=405248 Buffers: shared hit=210955 read=196338 dirtied=133 written=494 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..15567.77 rows=743120 width=0) (actual time=1184.328..1184.328 rows=748346 loops=1) Index Cond: ((l_shipdate >= '1994-04-01'::date) AND (l_shipdate < '1994-05-01'::date)) Buffers: shared hit=3 read=2042 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1523.163..1523.163 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=1932 read=38590 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.022..855.918 rows=2000000 loops=1) Buffers: shared hit=1932 read=38590 Planning time: 2.173 ms Execution time: 7491.443 ms (19 rows) COMMIT; COMMIT