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:
| Method | When it runs |
|---|---|
| Full synchronization | Collects complete column statistics on a scheduled basis |
| Incremental synchronization | Updates statistics based on data changes |
| Real-time synchronization | Reflects 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.