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-01-01' and l_shipdate < cast(date '1995-01-01' + interval '1 month' as date); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=1167749.19..1167749.21 rows=1 width=29) (actual time=7676.698..7676.698 rows=1 loops=1) Buffers: shared hit=230229 read=227858 dirtied=287 written=14670 -> Hash Join (cost=101771.15..1154308.19 rows=768057 width=29) (actual time=2289.006..7300.544 rows=774975 loops=1) Hash Cond: (lineitem.l_partkey = part.p_partkey) Buffers: shared hit=230229 read=227858 dirtied=287 written=14670 -> Bitmap Heap Scan on lineitem (cost=16249.15..1057265.34 rows=768057 width=12) (actual time=476.604..4398.877 rows=774975 loops=1) Recheck Cond: ((l_shipdate >= '1995-01-01'::date) AND (l_shipdate < '1995-02-01'::date)) Heap Blocks: exact=415440 Buffers: shared hit=226320 read=191242 dirtied=287 written=10243 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey__idx (cost=0.00..16057.14 rows=768057 width=0) (actual time=294.932..294.932 rows=779592 loops=1) Index Cond: ((l_shipdate >= '1995-01-01'::date) AND (l_shipdate < '1995-02-01'::date)) Buffers: shared hit=362 read=1760 written=191 -> Hash (cost=60522.00..60522.00 rows=2000000 width=25) (actual time=1790.362..1790.362 rows=2000000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 131903kB Buffers: shared hit=3906 read=36616 written=4427 -> Seq Scan on part (cost=0.00..60522.00 rows=2000000 width=25) (actual time=0.019..947.190 rows=2000000 loops=1) Buffers: shared hit=3906 read=36616 written=4427 Planning time: 2.662 ms Execution time: 7684.342 ms (19 rows) COMMIT; COMMIT