31.2 查询响应时间指数(QRTi)

QRTi 代表“查询响应时间指数”。它是每个查询的“服务质量”度量,并使用 Apdex 公式进行计算: 维基百科上的 Apdex

QRTi 是如何定义的

三个测量条件是“最优”、“可接受”和“不可接受”,定义为:

表 31.1 QRTi 值定义

类型 默认时间值 赋值 描述 颜色

最佳

100毫秒

1.00 (100%)

最佳时间范围

绿色的

可接受的

4 * 最佳——100 毫秒到 400 毫秒

0.50 (50%)

可接受的时间框架

黄色

不可接受

超出可接受范围——大于 400 毫秒

0.00 (0%)

无法接受的时间框架

红色的


示例计算

从那里,我们计算平均值以确定最终的 QRTi 值。例如,如果摘要/规范查询有 100 次执行,其中 60 次在 100 毫秒以下(最佳时间范围)完成,30 次在 100 毫秒和 400 毫秒之间(可接受的时间范围),其余 10 次花费的时间超过 400 毫秒(不可接受的时间) ),则 QRTi 分数为:

( (60 + (30 / 2) + (10*0) ) / 100) = 0.75.

读取 QRTi 值

The queries listed on the Query Analyzer page also have a color-coded pie chart representing a breakdown of the values used in the QRTi calculation; green representing the optimal percentage, yellow the acceptable percentage, and red the unacceptable percentage. You can mouse over the pie chart itself to see the total number of query executions that fell within each category, as well as the percentage of query executions that fell within that group.

So when doing query optimization, you want to start with the ones that have a QRTi visual pie chart that is 100% red, which means that they also have an actual QRTi value of 0. This means that *all* executions of that query took longer than the acceptable time frame (400ms by default). You can then click on the query to get more information, such as the maximum and average query times, the average number of rows examined, the average lock wait time, examine a sample query, look at an example EXPLAIN plan, see if full table scans were done, examine index usage, etc.

You can then work your way up from the queries with a QRTi value of 0, towards those that have a value of 1 (1 meaning that all instances of the query executed within the optimal time frame). Once you get to the point that you no longer have any queries with a QRTi value of less than 1, then you can go into the Query Analysis Reporting Advisor configuration, and adjust the QRTi Threshold (the target time) down, say to 50ms, and start the process all over again.