首批通过分布式安全可靠测评,为关键业务系统打造
GV$SYSSTAT 中租户 cpu_usage 的统计方法
更新时间:2026-05-18 01:51
gv$sysstat 中关于租户的线程使用率是基于租户线程的调度情况计算得到,而非基于物理的 CPU 使用。
gv$sysstat 中的 cpu_usage 是按照租户维度统计的,其对应的 stat_id 为 140006。
obclient [oceanbase]> select * from gv$sysstat where stat_id in (140006,140005) and con_id=1001;
+--------+---------------+----------+------------+-------+---------+-----------+-------+
| CON_ID | SVR_IP | SVR_PORT | STATISTIC# | VALUE | STAT_ID | NAME | CLASS |
+--------+---------------+----------+------------+-------+---------+-----------+-------+
| 1001 | 11.xxx.xx.xxx | 2882 | 589 | 300 | 140005 | max cpus | 64 |
| 1001 | 11.xxx.xx.xxx | 2882 | 590 | 0 | 140006 | cpu usage | 64 |
| 1001 | 11.xxx.xx.xxx | 2882 | 589 | 300 | 140005 | max cpus | 64 |
| 1001 | 11.xxx.xx.xxx | 2882 | 590 | 0 | 140006 | cpu usage | 64 |
| 1001 | 11.xxx.xx.xxx | 2882 | 589 | 300 | 140005 | max cpus | 64 |
| 1001 | 11.xxx.xx.xxx | 2882 | 590 | 0 | 140006 | cpu usage | 64 |
+--------+---------------+----------+------------+-------+---------+-----------+-------+
cpu_usage 的计算方法为 cpu_usage = token_usage/cpu_quota_concurrency。
其中,cpu_quota_concurrency 为系统配置项,定义了一个 CPU 最多可以并行执行的租户线程数;token_usage 统计了租户所有 worker 线程的使用情况。
max_cpus 的计算方法为 max_cpus = max_cpu*100。
其中,max_cpu 为租户 unit 的 max_cpu。
适用版本
OceanBase 数据库 V4.0 之前的版本。