Why it matters
CBO is one of the largest wins for Hive performance. On join-heavy queries, CBO with fresh stats can produce plans 10x faster than the fallback rule-based optimizer.
The architecture
CBO uses Calcite as its planner framework. Calcite explores alternative plans (join orders, join implementations, aggregation placements) and picks the lowest-cost.
Cost model considers I/O (bytes read), CPU (row processing), and network (shuffle bytes). Costs are estimated using stats.
How it works end to end
Join reordering: CBO picks the order that minimizes intermediate result sizes. Small tables get joined first; large tables last.
Join strategy selection: CBO picks between broadcast (small side broadcast to every node), shuffle (both sides hashed by join key), and bucket join (aligned buckets, no shuffle).
Predicate pushdown: filters move as close to scans as possible, minimizing data processed by later operators.