Azure Database for MySQL 中的性能建议Performance Recommendations in Azure Database for MySQL

备注

将要查看的是 Azure Database for MySQL 的新服务。You are viewing the new service of Azure Database for MySQL. 若要查看经典 MySQL Database for Azure 的文档,请访问此页To view the documentation for classic MySQL Database for Azure, please visit this page.

适用于: Azure Database for MySQL 5.7、8.0Applies to: Azure Database for MySQL 5.7, 8.0

性能建议功能会分析数据库,为改进性能创建自定义建议。The Performance Recommendations feature analyzes your databases to create customized suggestions for improved performance. 为了生成建议,分析将查看各种数据库特征(包括架构)。To produce the recommendations, the analysis looks at various database characteristics including schema. 启用服务器上的查询存储即可充分利用性能建议功能。Enable Query Store on your server to fully utilize the Performance Recommendations feature. 如果性能架构为 OFF,则打开查询存储会启用 performance_schema 以及此功能所需的一部分性能架构检测。If performance schema is OFF, turning on Query Store enables performance_schema and a subset of performance schema instruments required for the feature. 实施任何性能建议后,应测试性能以评估这些更改的影响。After implementing any performance recommendation, you should test performance to evaluate the impact of those changes.

权限Permissions

使用性能建议功能运行分析所需的“所有者”或“参与者”权限。Owner or Contributor permissions required to run analysis using the Performance Recommendations feature.

性能建议Performance recommendations

性能建议功能跨服务器分析工作负载以标识可能会提高性能的索引。The Performance Recommendations feature analyzes workloads across your server to identify indexes with the potential to improve performance.

从 MySQL 服务器的 Azure 门户页菜单栏的“智能性能”部分打开性能建议Open Performance Recommendations from the Intelligent Performance section of the menu bar on the Azure portal page for your MySQL server.

性能建议登陆页面

选择“分析”并选择数据库就会开始分析。Select Analyze and choose a database, which will begin the analysis. 分析可能需要几分钟的时间才能完成,具体取决于工作负载。Depending on your workload, the analysis may take several minutes to complete. 分析完成后,门户中将出现通知。Once the analysis is done, there will be a notification in the portal. 分析会执行数据库的深层检查。Analysis performs a deep examination of your database. 建议在非高峰期执行分析。We recommend you perform analysis during off-peak periods.

“建议”窗口会显示找到的建议的列表,以及生成该建议的相关查询 ID。The Recommendations window will show a list of recommendations if any were found and the related query ID that generated this recommendation. 有了查询 ID,就可以使用 mysql.query_store 视图来详细了解查询。With the query ID, you can use the mysql.query_store view to learn more about the query.

性能建议新页

不会自动应用建议。Recommendations are not automatically applied. 若要应用建议,请复制查询文本并从所选的客户端中运行。To apply the recommendation, copy the query text and run it from your client of choice. 记住通过测试和监视来评估建议。Remember to test and monitor to evaluate the recommendation.

建议类型Recommendation types

索引建议Index recommendations

“创建索引”建议建议使用新索引来加快工作负载中最常运行或最耗时的查询。Create Index recommendations suggest new indexes to speed up the most frequently run or time-consuming queries in the workload. 此建议类型需要启用查询存储This recommendation type requires Query Store to be enabled. 查询存储收集查询信息并提供详细的查询运行时和频率统计信息,供分析用来提出建议。Query Store collects query information and provides the detailed query runtime and frequency statistics that the analysis uses to make the recommendation.

查询建议Query recommendations

查询建议建议对工作负载中的查询进行优化和重写。Query recommendations suggest optimizations and rewrites for queries in the workload. 通过识别 MySQL 查询反模式并按句法修复它们,可以改进耗时查询的性能。By identifying MySQL query anti-patterns and fixing them syntactically, the performance of time-consuming queries can be improved. 此建议类型需要启用“查询存储”。This recommendation type requires Query Store to be enabled. 查询存储收集查询信息并提供详细的查询运行时和频率统计信息,供分析用来提出建议。Query Store collects query information and provides the detailed query runtime and frequency statistics that the analysis uses to make the recommendation.

后续步骤Next steps