NEW
Also known as: CBO
A query optimizer that evaluates alternative execution plans using estimated costs to choose the most efficient one.
DESCRIPTION
A cost-based optimizer assigns estimated costs to different execution strategies based on statistics, cardinality, and operator models. It explores join orders, access paths, and physical operators to minimize resource consumption or latency. Accurate statistics are critical to good plan selection. CBOs may use dynamic sampling, histograms, and feedback to improve estimates. They often support hints to guide or override decisions. Modern optimizers balance exhaustive search with heuristics to control compilation time. Adaptive techniques can refine plans during execution.
ALTERNATIVE DEFINITIONS
Oracle Database Documentation
The optimizer chooses the most efficient execution plan based on the estimated cost of alternative plans.
Classic description from Oracle highlighting cost-based plan selection.
PostgreSQL Documentation
The planner/optimizer attempts to determine the cheapest way to execute a given query.
Emphasizes cost minimization as the primary goal of the planner.
Microsoft Learn
The Query Optimizer generates a query plan that it estimates will yield the fastest execution.
Focuses on estimating execution time to choose a plan.
RELATED TERMS
Query Planner Cardinality Estimation Statistics Join Order Optimization Query Execution Plan Query Hints Selectivity Index Selection Predicate Pushdown
COMPETING TERMS
RELATIONS
- Broader: Optimizer
KNOWLEDGE AREAS
Data Storage & Operations Data Engineering Data Warehousing & BI Software Engineering
TARGET AUDIENCE
Data Engineer Software Developer Data Architect BI Specialist
EXTERNAL SOURCES
- Wikipedia - Query optimizer
- Oracle - Oracle cost-based optimizer overview
- PostgreSQL Documentation - Planner/optimizer concepts
- Microsoft - SQL Server query optimizer guide
TOP QUESTIONS
Why is the Cost-Based Optimizer crucial for performance?
It chooses efficient execution plans that minimize I/O and CPU. Good plans can improve performance orders of magnitude compared to naive strategies.
Category: Relevancy
What data does a Cost-Based Optimizer rely on?
Accurate table and index statistics, histograms, and cardinality estimates. It also uses operator cost models and metadata about indexes and partitions.
Category: Requirements
What are common mistakes affecting the Cost-Based Optimizer?
Stale or missing statistics, inappropriate parameter sniffing, and misuse of hints can lead to poor plan choices and regressions.
Category: Mistakes
How does a Cost-Based Optimizer differ from a Rule-Based Optimizer?
CBO evaluates costs using statistics, while RBO applies fixed heuristics. CBO is generally superior for complex queries and diverse data distributions.
Category: Alternatives
What is plan instability in Cost-Based Optimization?
Small data or parameter changes can trigger different join orders or operators. Plan guides, hints, or baselines can mitigate instability.
Category: Risks
Can I force a plan with hints?
Yes, most systems support hints to influence join order, index use, or operators. Use sparingly and document reasons to avoid long-term debt.
Category: Best practices
What is cardinality estimation?
It predicts the number of rows flowing between operators. Accurate estimates are vital for selecting join strategies and index usage.
Category: Example
How do CBOs handle very large search spaces?
They combine heuristics, dynamic programming, and pruning to limit exploration, balancing optimization time with plan quality.
Category: Opinion
What’s a hot topic around CBO today?
Adaptive query processing and feedback loops that refine estimates during execution are increasingly common in modern engines.
Category: Topic