要衡量绩效,请考虑以下因素:To measure performance, consider the following factors:
无论您是在测量在空闲系统上单个操作的速度,还是测量一组操作(一个“工作负载””)在一段时间内的表现。通过简单的测试,您通常会测试改变某一方面(配置设置、表上的索引集合、查询中的 SQL 子句)如何影响性能。基准测试通常是长期运行且复杂的性能测试,其结果可能决定诸如硬件和存储配置的高层次选择,或者决定何时升级到新的 MySQL 版本。Whether you are measuring the speed of a single operation on a quiet system, or how a set of operations (a “workload”) works over a period of time. With simple tests, you usually test how changing one aspect (a configuration setting, the set of indexes on a table, the SQL clauses in a query) affects performance. Benchmarks are typically long-running and elaborate performance tests, where the results could dictate high-level choices such as hardware and storage configuration, or how soon to upgrade to a new MySQL version.
为了基准测试,有时你必须模拟一个繁重的数据库工作负载,以获得准确的情况。For benchmarking, sometimes you must simulate a heavy database workload to get an accurate picture.
性能可能会因许多不同因素而变化,因此几个百分点的差异可能不是决定性的胜利。在不同环境下测试时,结果可能会出现相反的情况。Performance can vary depending on so many different factors that a difference of a few percentage points might not be a decisive victory. The results might shift the opposite way when you test in a different environment.
某些 MySQL 功能根据工作负载的不同可能会提高或降低性能。为了完整起见,总是应该在这些功能开启和关闭的情况下测试性能。对于每种工作负载最重要的功能是 InnoDB 表的
InnoDB。Certain MySQL features help or do not help performance depending on the workload. For completeness, always test performance with those features turned on and turned off. The most important feature to try with each workload is the adaptive hash index forInnoDBtables.
本节内容从单个开发者可以进行的简单直接的测量方法开始,逐步过渡到需要额外专业知识来执行和解释结果的更复杂方法。This section progresses from simple and direct measurement techniques that a single developer can do, to more complicated ones that require additional expertise to perform and interpret the results.