南大通用GBase 8a 内存缓冲信息元数据表CACHE_usage_info的介绍

GBase 8a 提供了查看当前系统运行期状况的元数据表,其中performance_schema.CACHE_usage_info表包含了当前服务的内存缓冲信息,以及每个DC的具体详情CACHE_CELL_STATUS_INFO。本文介绍该表的使用方法。

该功能,需要打开数据库统计内存功能才可看到数据。 GBase 8a集群统计运行期内存使用情况_gbase_session_memory_stat参数

CACHE_usage_info 元数据表

说明

字段类型说明
HOSTvarchar(64)主机名字,就是本机
TOTAL_DCbigint(16)DC总数量
UNLOCKED_DCbigint(16)没有被锁住的DC总数量(表示可以被redlease释放)
TOTAL_DC_SIZEbigint(16)DC占用总内存大小(单位:字节)
UNLOCKED_DC_SIZEbigint(16)没有被锁住的DC占用内存大小(单位:字节)
HOT_TOTAL_DCbigint(16)热数据DC数量
HOT_UNLOCKED_DCbigint(16)没有被锁住的热数据DC数量
HOT_TOTAL_DC_SIZEbigint(16)热数据DC占用总内存大小(单位:字节)
HOT_UNLOCKED_DC_SIZEbigint(16)没有被锁住的热数据DC占用内存大小(单位:字节)
COLD_TOTAL_DCbigint(16)冷数据DC数量
COLD_UNLOCKED_DCbigint(16)没有被锁住的冷数据DC数量
COLD_TOTAL_DC_SIZEbigint(16)冷数据DC占用总内存大小(单位:字节)
COLD_UNLOCKED_DC_SIZEbigint(16)没有被锁住的冷数据DC占用内存大小(单位:字节)
HIT_RATEvarchar(16)DC命中率
performance_schema.cache_usage_info 内存缓冲信息元数据表

使用样例

默认没有缓冲时

全部数值为0

gbase> select * from CACHE_usage_info;
+-------+----------+-------------+---------------+------------------+--------------+-----------------+-------------------+----------------------+---------------+------------------+--------------------+-----------------------+----------+
| HOST  | TOTAL_DC | UNLOCKED_DC | TOTAL_DC_SIZE | UNLOCKED_DC_SIZE | HOT_TOTAL_DC | HOT_UNLOCKED_DC | HOT_TOTAL_DC_SIZE | HOT_UNLOCKED_DC_SIZE | COLD_TOTAL_DC | COLD_UNLOCKED_DC | COLD_TOTAL_DC_SIZE | COLD_UNLOCKED_DC_SIZE | HIT_RATE |
+-------+----------+-------------+---------------+------------------+--------------+-----------------+-------------------+----------------------+---------------+------------------+--------------------+-----------------------+----------+
| rh6-2 |        0 |           0 |             0 |                0 |            0 |               0 |                 0 |                    0 |             0 |                0 |                  0 |                     0 | 100%     |
+-------+----------+-------------+---------------+------------------+--------------+-----------------+-------------------+----------------------+---------------+------------------+--------------------+-----------------------+----------+
1 row in set (Elapsed: 00:00:00.00)

查询一个表后

该表有50万行,8个DC(每个DC 65536行)。可以看到缓冲的DC数量为8. 命中率30%。

gbase> select * from testdb.t1_n1;
+-------+------+
| id    | name |
+-------+------+
|   222 | NULL |
|  5105 | NULL |
| 18263 | NULL |
| 16969 | NULL |

|  6116 | NULL |
^C| 13664 | Query aborted by Ctrl+C
NULL |
+-------+------+
500001 rows in set (Elapsed: 00:00:00.61)

gbase> select * from CACHE_usage_info;
ERROR 1317 (70100): Query execution was interrupted
gbase> select * from CACHE_usage_info;
+-------+----------+-------------+---------------+------------------+--------------+-----------------+-------------------+----------------------+---------------+------------------+--------------------+-----------------------+----------+
| HOST  | TOTAL_DC | UNLOCKED_DC | TOTAL_DC_SIZE | UNLOCKED_DC_SIZE | HOT_TOTAL_DC | HOT_UNLOCKED_DC | HOT_TOTAL_DC_SIZE | HOT_UNLOCKED_DC_SIZE | COLD_TOTAL_DC | COLD_UNLOCKED_DC | COLD_TOTAL_DC_SIZE | COLD_UNLOCKED_DC_SIZE | HIT_RATE |
+-------+----------+-------------+---------------+------------------+--------------+-----------------+-------------------+----------------------+---------------+------------------+--------------------+-----------------------+----------+
| rh6-2 |        8 |           8 |       1000098 |          1000098 |            8 |               8 |           1000098 |              1000098 |             0 |                0 |                  0 |                     0 | 30%      |
+-------+----------+-------------+---------------+------------------+--------------+-----------------+-------------------+----------------------+---------------+------------------+--------------------+-----------------------+----------+
1 row in set (Elapsed: 00:00:00.00)

gbase> select * from CACHE_usage_info\G;
*************************** 1. row ***************************
                 HOST: rh6-2
             TOTAL_DC: 8
          UNLOCKED_DC: 8
        TOTAL_DC_SIZE: 1000098
     UNLOCKED_DC_SIZE: 1000098
         HOT_TOTAL_DC: 8
      HOT_UNLOCKED_DC: 8
    HOT_TOTAL_DC_SIZE: 1000098
 HOT_UNLOCKED_DC_SIZE: 1000098
        COLD_TOTAL_DC: 0
     COLD_UNLOCKED_DC: 0
   COLD_TOTAL_DC_SIZE: 0
COLD_UNLOCKED_DC_SIZE: 0
             HIT_RATE: 30%
1 row in set (Elapsed: 00:00:00.00)

再次查询该表的100行

命中率增加到了36.36%,全部是热数据。

gbase> select * from testdb.t1_n1 limit 100;
+-------+------+
| id    | name |
+-------+------+
|   222 | NULL |
。。。。。。
| 23793 | NULL |
+-------+------+
100 rows in set (Elapsed: 00:00:00.00)

gbase> select * from CACHE_usage_info\G;
*************************** 1. row ***************************
                 HOST: rh6-2
             TOTAL_DC: 8
          UNLOCKED_DC: 8
        TOTAL_DC_SIZE: 1000098
     UNLOCKED_DC_SIZE: 1000098
         HOT_TOTAL_DC: 8
      HOT_UNLOCKED_DC: 8
    HOT_TOTAL_DC_SIZE: 1000098
 HOT_UNLOCKED_DC_SIZE: 1000098
        COLD_TOTAL_DC: 0
     COLD_UNLOCKED_DC: 0
   COLD_TOTAL_DC_SIZE: 0
COLD_UNLOCKED_DC_SIZE: 0
             HIT_RATE: 36.36%
1 row in set (Elapsed: 00:00:00.00)

DC详细信息源数据表 CACHE_CELL_STATUS_INFO

说明

字段类型说明
TABLE_IDbigint(16)表编号(GBase 8a查看表的tableId)
COLUMN_IDbigint(16)列编号,从0开始
DPbigint(16)DC的位置,从0开始
LOCK_COUNTbigint(16)被锁的次数
LOCKEDbigint(16)锁住状态,1=是,0=否
SIZEbigint(16)占用内存大小
GBase 8a集群DC详细信息源数据表 CACHE_CELL_STATUS_INFO

样例
如下是前面的内存缓冲表数据,每个DC的情况信息

gbase> select * from CACHE_CELL_STATUS_INFO;
+----------+-----------+----+------------+--------+--------+
| TABLE_ID | COLUMN_ID | DP | LOCK_COUNT | LOCKED | SIZE   |
+----------+-----------+----+------------+--------+--------+
|   243717 |         0 |  6 |          0 |      0 | 131084 |
|   243717 |         0 |  7 |          0 |      0 |  82510 |
|   243717 |         0 |  3 |          0 |      0 | 131084 |
|   243717 |         0 |  2 |          0 |      0 | 131084 |
|   243717 |         0 |  5 |          0 |      0 | 131084 |
|   243717 |         0 |  1 |          0 |      0 | 131084 |
|   243717 |         0 |  4 |          0 |      0 | 131084 |
|   243717 |         0 |  0 |          0 |      0 | 131084 |
+----------+-----------+----+------------+--------+--------+
8 rows in set (Elapsed: 00:00:00.00)