All Products
Search
Document Center

AnalyticDB:Cost-based SQL optimization

Last Updated:Mar 28, 2026

AnalyticDB for MySQL uses a cost-based optimizer (CBO) to automatically generate the lowest-cost query execution plan for each query. The CBO handles complex analytical workloads without requiring manual tuning.

How the CBO works

Before executing a query, the CBO evaluates multiple candidate execution plans and selects the one with the lowest estimated cost. It searches across four dimensions simultaneously: JOIN order, data shuffle mode, index selection, and aggregation method. Searching all four dimensions at once—rather than using the layered search that traditional optimizers rely on—lets the CBO find better plans for complex multi-table queries and large aggregations.

Cost estimates depend on accurate, up-to-date statistics. AnalyticDB for MySQL automatically collects and maintains statistics for all table columns using three synchronization methods:

MethodWhen it runs
Full synchronizationCollects complete column statistics on a scheduled basis
Incremental synchronizationUpdates statistics based on data changes
Real-time synchronizationReflects the latest data state as changes occur

All statistics collection runs in the background without affecting your business.

Distributed execution

The CBO generates execution plans optimized for distributed execution across multiple nodes. Query results are returned in real time, including for complex joins and large aggregations.