南大通用GBase 8a 查看某张表的热数据内存缓冲总量

GBase 8a的计算节点,提供了performance_schema.CACHE_CELL_STATUS_INFO表,记录了DC缓冲信息,通过累计其内存总量,可以计算某张表占用的内存热数据缓冲总量。

参考

DC详细信息源数据表 CACHE_CELL_STATUS_INFO

查询方法

注意只有计算节点gnode才缓冲数据,目前调度节点还没有自动汇总所有节点内存总和的功能,所以需要逐个节点查询。

通过库名,表名和分片号,查询到table_id

gbase> select table_id from information_schema.tables where table_schema='ab' and table_name='t1_n1';
+----------+
| table_id |
+----------+
|      118 |
+----------+
1 row in set (Elapsed: 00:00:00.00)

通过table_id,查询详细的DC缓存信息

数据越多,量越多,不建议查询明细。 注意里面有列(column_id)

gbase> select * from CACHE_CELL_STATUS_INFO where table_id=118 order by dp;
+----------+-----------+-----+------------+--------+--------+
| TABLE_ID | COLUMN_ID | DP  | LOCK_COUNT | LOCKED | SIZE   |
+----------+-----------+-----+------------+--------+--------+
|      118 |         0 |   0 |          0 |      0 | 131084 |
|      118 |         0 |   1 |          0 |      0 | 131084 |
|      118 |         0 |   2 |          0 |      0 | 131084 |
|      118 |         0 |   3 |          0 |      0 | 131084 |
|      118 |         0 |   4 |          0 |      0 | 131084 |
|      118 |         0 |   5 |          0 |      0 | 131084 |
|      118 |         0 |   6 |          0 |      0 | 131084 |
................
|      118 |         0 | 300 |          0 |      0 | 131084 |
|      118 |         0 | 301 |          0 |      0 | 131084 |
|      118 |         0 | 302 |          0 |      0 | 131084 |
|      118 |         0 | 303 |          0 |      0 | 131084 |
|      118 |         0 | 304 |          0 |      0 | 131084 |
+----------+-----------+-----+------------+--------+--------+
305 rows in set (Elapsed: 00:00:00.00)

累计表占用的内存

gbase> select sum(size) from CACHE_CELL_STATUS_INFO where table_id=118;
+-----------+
| sum(size) |
+-----------+
|  39980620 |
+-----------+
1 row in set (Elapsed: 00:00:00.00)

综合使用

gbase> select sum(size) from CACHE_CELL_STATUS_INFO where table_id=(select table_id from information_schema.tables where table_schema='ab' and table_name='t1_n1');
+-----------+
| sum(size) |
+-----------+
|  39980620 |
+-----------+
1 row in set (Elapsed: 00:00:00.00)