首批通过分布式安全可靠测评,为关键业务系统打造
SQL 性能诊断相关参数配置
更新时间:2024-12-04 14:15:50
本节描述 OCP 系统参数中与 SQL 性能诊断相关的参数配置。
SQL 性能模块
表中介绍 SQL 性能诊断参数的配置,表中所属"诊断对象"都是针对 SQL。
| 参数名 | 默认值 | 参数说明 |
|---|---|---|
| ocp.perf.sql-diag.awful-performance-index-used-config | {"enabled":true, "cpuTimeLimitUs":100000, "execPsLimit":5.0, "fullLogicalReadsLimit":10000} | 走索引性能依然差的诊断配置。 |
| ocp.perf.sql-diag.cpu-time-proportion-high-config | {"enabled":true, "cpuTimeLimitUs":10000, "execPsLimit":10.0, "maxCpuTimeLimitUs":30000, "affectedRowsLimit":100, "execLimit":30, "sqlCountLimit":20, "cpuTimePercentLimit":20} | 执行占比较高诊断的配置。 判断标准:诊断时间内,被诊断的 SQL 的 CPU 时间占租户 CPU 时间超过 $cpuTimePercentLimit,且租户的 SQL 执行总次数大于 $execLimit,且租户执行的不同 SQL 数大于 $sqlCountLimit,则视为占比过高。 |
| ocp.perf.sql-diag.database-white-list | oceanbase,information_schema,mysql,__recyclebin,sys,__public | SQL 诊断时过滤掉的数据库名。 |
| ocp.perf.sql-diag.execution-spike-config | {"enabled":true, "cpuTimeLimitUs":3000, "execPsLimit":5.0, "pointsLimit":5, "compareMin":20, "avgExecutionMultiply":{"0":6, "1":5, "5":4, "10":3, "50": 2.5, "100": 2, "500": 1.6}, "stdExecutionMultiply":{"0":80, "1":60 , "3": 30,"5":20, "10":15, "20":8, "30":6, "50":5, "80":4}} | 执行次数突刺诊断的配置。 判断标准: 1. 取前 $compareMin 时间内满足诊断对象条件的 SQL,统计这些 SQL 前 compareMin 时间内每分钟执行频率的均值 avg_exec_ps,以及前 $compareMin 时间内执行频率的标准差 std_exec_ps 和标准差与均值的百分比 range_percent,即统计如下信息:历史平均执行频率(avg_exec_ps),标准差(std_exec_ps)* range_percent(std_exec_ps / avg_exec_ps * 100)。 2. 然后计算该 SQL 的平均每秒执行次数(exec_ps)。当 exec_ps 同时满足以下条件时则该 SQL 被认为是执行次数突刺。 exec_ps>=avg_exec_ps*$multiple_value_1* exec_ps >= avg_exec_ps + std_exec_ps * $multiple_value_2 说明multiple_value_1,随 avg_exec_ps 变化情况,依赖配置项 avgExecutionMultiply。 |
| ocp.perf.sql-diag.index-diagnoser-config | {"enabled":true,"schedulePeriodMin":5, "coreThreadSize":10, "maxThreadSize":50,"maxQueueSize":10000,"diagPeriodSec":300,"diagOffsetSec":60,"maxDiagPeriodSec":1800} | SQL 索引诊断配置参数,重启生效。 不建议用户自行配置。 |
| ocp.perf.sql-diag.ineffective-hint-config | {"enabled":true, "execPsLimit":5.0, "cpuTimeLimitUs":20000} | Hint 未生效诊断的配置。 判断标准:解析诊断对象,满足 "Hint 中指定的索引的与执行计划里的不一致。" 则认为是 Hint 未生效。 |
| ocp.perf.sql-diag.perf-diagnoser-config | {"enabled":true,"schedulePeriodMin":5, "coreThreadSize":10, "maxThreadSize":50,"maxQueueSize":10000,"diagPeriodSec":300,"diagOffsetSec":60,"maxDiagPeriodSec":1800} | SQL 性能诊断配置参数,重启生效。 不建议用户自行配置。 |
| ocp.perf.sql-diag.performance-degradation-after-plan-changed-config | {"enabled":true, "compareMin":5, "cpuTimeLimitMs":1.0, "cpuTimeMultiply":{"0":50, "1":30, "10":10, "100":8, "1000":6}} | 执行计划变化且性能下降诊断的配置。 |
| ocp.perf.sql-diag.performance-degradation-config | {"enabled":true, "cpuTimeLimitUs":10000, "execPsLimit":5.0, "maxCpuTimeLimitUs":30000, "affectedRowsLimit":100, "execLimit":5, "compareMin":20, "cpuTimeMultiply":{"0":50, "1":30, "10":10, "100":8, "1000":6}} | 性能下降诊断的配置。 判断标准: 基线作为比较对象,需满足"基线执行次数 > $execLimit",否则不可作为比较对象。有了比较对象后,当检测的 SQL 同时满足下述条件则认为是性能比以前下降。 |
| ocp.perf.sql-diag.query-timeout | 30000000 | SQL 诊断查询时的超时时间(μs)。 |
| ocp.perf.sql-diag.row-lock-contention-high-config | {"enabled":true, "execPsLimit":0, "cpuTimeLimitUs":1000, "elapsedTimeLimitUs":0} | 热点行锁诊断的配置。 执行频率 > $execPsLimit && 平均 CPU 时间 > $cpuTimeLimitUs && 平均响应时间 > $elapsedTimeLimitUs 。 说明elapsedTimeLimitUs 不配置的话,则不作为过滤检测对象的条件。 |
| ocp.perf.sql-diag.table-scan-index-not-exists-config | {"enabled":true, "execPsLimit":1.0, "cpuTimeLimitUs":20000} | 全表扫描且无可用索引的诊断配置。 判断标准:满足下述条件则认为是无索引。 |
| ocp.perf.sql-diag.table-scan-index-not-used-config | {"enabled":true, "execPsLimit":1.0, "cpuTimeLimitUs":2000} | 全表扫描有索引未走的诊断配置。 执行频率 > $execPsLimit && 平均 CPU 时间 > $cpuTimeLimitUs && 进行了全变扫描。 判断标准:有索引未走。 |
| ocp.perf.sql.diag-plan-change-config | {"enabled":true,"schedulePeriodMin":5, "coreThreadSize":10, "maxThreadSize":50,"maxQueueSize":10000,"diagPeriodSec":300,"diagOffsetSec":300,"maxDiagPeriodSec":1800} | 诊断任务调度参数配置。 不建议用户自行配置。 |
| ocp.perf.sql.max-query-range | 24h | SQL 性能数据查询时的最大时间区间长度。默认值"24h"。 若 TopSQL 和 SlowSQL 界面配置的查询时间超过该值,则提交查询时会报错。 |
| ocp.perf.sql.plan-hist-level0-granularity | 30s | OCP 聚合第 0 级 SQL 的 Plan 性能数据的时间粒度。 OCP 默认 30s 采集并聚合一次 SQL 的 Plan 性能数据并存于固定表中,供 TopSQL 查询时使用。 通过调大该值可以降低 OCP 监控元数据存储空间的压力。 |
| ocp.perf.sql.plan-hist-level0-query-interval | 2h | 第 0 级 Plan 性能数据的最大查询时间区间。 超过该值,OCP 会去查看聚合时间粒度更大的数据表。 |
| ocp.perf.sql.plan-hist-level0-retention | 5d | 第 0 级 Plan 性能数据的分区保留时间。 性能数据的分区按天创建,系统默认只保留 5 天内的数据,超过 5 天的分区将会被删除。 |
| ocp.perf.sql.prepare-partition-ahead | 8 | 指定提前创建多少天的性能数据分区。要求传入以天为单位的时间。 |
| ocp.perf.sql.query-timeout | 30000000 | SQL 性能数据查询时的超时时间(μs)。 |
| ocp.perf.sql.sql-hist-level0-granularity | 30s | OCP 聚合第 0 级 SQL 性能数据的时间粒度。
说明为提高 OCP 监控采集性能,OCP 将按不同的时间粒度采集并聚合 SQL 的性能数据以供 TopSQL 的诊断时查询。共分三级,不同级别的数据被采集来后会按天存储到对应级别表的分区中。分区的保留时间由固定参数配置。 |
| ocp.perf.sql.sql-hist-level0-query-interval | 2h | 第 0 级 SQL 性能数据的最大查询时间区间。 当用户在 TopSQL 界面中配置的查询时间区间超过该值时,系统将会从第 1 级 SQL 性能数据表中查询。 |
| ocp.perf.sql.sql-hist-level0-retention | 2d | 第 0 级 SQL 性能数据的分区保留时间。 对于按天创建用来存储第 0 级 SQL 性能数据的分区表,监控元数据库默认仅保留两天内创建的。 |
| ocp.perf.sql.sql-hist-level1-granularity | 2m | OCP 聚合第 1 级 SQL 性能数据的时间粒度。OCP 默认每 2 分钟聚合一次 SQL 性能数据并写入第 2 级 SQL 性能数据表中。 |
| ocp.perf.sql.sql-hist-level1-query-interval | 12h | 第1级SQL性能数据的最大查询时间区间。 当用户在 TOPSQL 界面中配置的查询时间区间超过该值时,系统将会从第 2 级 SQL 性能数据表中查询。 |
| ocp.perf.sql.sql-hist-level1-retention | 8d | 第 1 级 SQL 性能数据的分区保留时间。 |
| ocp.perf.sql.sql-hist-level2-granularity | 10m | OCP 聚合第 2 级 SQL 性能数据的时间粒度。OCP 默认每 10 分钟聚合一次 SQL 性能数据并写入第 2 级 SQL 性能数据表中。 |
| ocp.perf.sql.sql-hist-level2-query-interval | 48h | 第 2 级 SQL 性能数据的最大查询时间区间。 因无更高级别的的采集粒度,即使超过该值,OCP 仍会从第 2 级 SQL 性能数据表中查询。 |
| ocp.perf.sql.sql-hist-level2-retention | 15d | 第 2 级 SQL 性能数据的分区保留时间。 |