数据仓库服务 GAUSSDB(DWS)-用户资源监控:操作步骤

时间:2024-01-19 16:49:27

操作步骤

  • 查询所有用户的资源限额和资源实时使用情况。
    1
    SELECT * FROM PG_TOTAL_USER_RESOURCE_INFO;
    

    得到的结果视图如下:

    1
    2
    3
    4
    5
    6
    7
    username        | used_memory | total_memory | used_cpu | total_cpu | used_space | total_space | used_temp_space | total_temp_space | used_spill_space | total_spill_space | read_kbytes | write_kbytes | read_counts | write_counts | read_speed | write_speed
    -----------------------+-------------+--------------+----------+-----------+------------+-------------+-----------------+------------------+------------------+-------------------+-------------+--------------+-------------+--------------+------------+-------------
    perfadm               |           0 |            0 |        0 |         0 |          0 |          -1 |               0 |               -1 |                0 |                -1 |           0 |            0 |           0 |            0 |          0 |           0
    usern                 |           0 |        17250 |        0 |        48 |          0 |          -1 |               0 |               -1 |                0 |                -1 |           0 |            0 |           0 |            0 |          0 |           0
    userg                 |          34 |        15525 |    23.53 |        48 |          0 |          -1 |               0 |               -1 |        814955731 |                -1 |     6111952 |      1145864 |      763994 |       143233 |      42678 |        8001
    userg1                |          34 |        13972 |    23.53 |        48 |          0 |          -1 |               0 |               -1 |        814972419 |                -1 |     6111952 |      1145864 |      763994 |       143233 |      42710 |        8007
    (4 rows)
    

    其中,IO资源监控字段(read_kbytes、write_kbytes、read_counts、write_counts、read_speed和write_speed)需要在GUC参数enable_user_metric_persistent开启时才有监控数据。

    所查各字段说明详见PG_TOTAL_USER_RESOURCE_INFO

  • 查询具体某个用户的资源限额和资源实时使用情况。
    1
    SELECT * FROM GS_WLM_USER_RESOURCE_INFO('username');
    

    查询结果如下:

    1
    2
    3
    4
    userid | used_memory | total_memory | used_cpu | total_cpu | used_space | total_space | used_temp_space | total_temp_space | used_spill_space | total_spill_space | read_kbytes | write_kbytes | read_counts | write_counts | read_speed | write_speed
    --------+-------------+--------------+----------+-----------+------------+-------------+-----------------+------------------+------------------+-------------------+-------------+--------------+-------------+--------------+------------+-------------
    16407 |           18 |        1655 |        6 |         19 |          13787176 |          -1 |               0 |               -1 |                0 |                -1 |           0 |            0 |           0 |            0 |          0 |           0
    (1 row)
    
  • 查询所有用户的资源限额和资源历史使用情况。
    1
    SELECT * FROM GS_WLM_USER_RESOURCE_HISTORY;
    

    查询结果如下:

    1
    2
    3
    4
    5
    username        |           timestamp           | used_memory | total_memory | used_cpu | total_cpu | used_space | total_space | used_temp_space | total_temp_space | used_spill_space | total_spill_space | read_kbytes | write_kbytes | read_counts | write_counts | read_speed  | write_speed
    -----------------------+-------------------------------+-------------+--------------+----------+-----------+------------+-------------+-----------------+------------------+------------------+-------------------+-------------+--------------+-------------+--------------+-------------+-------------
    usern                 | 2020-01-08 22:56:06.456855+08 |           0 |        17250 |        0 |        48 |          0 |          -1 |               0 |               -1 |         88349078 |                -1 |       45680 |           34 |        5710 |            8 |         320 |           0
    userg                 | 2020-01-08 22:56:06.458659+08 |           0 |        15525 |    33.48 |        48 |          0 |          -1 |               0 |               -1 |        110169581 |                -1 |       17648 |           23 |        2206 |            5 |         123 |           0
    userg1                | 2020-01-08 22:56:06.460252+08 |           0 |        13972 |    33.48 |        48 |          0 |          -1 |               0 |               -1 |        136106277 |                -1 |       17648 |           23 |        2206 |            5 |         123 |           0
    

    对于系统表GS_WLM_USER_RESOURCE_HISTORY,仅当GUC参数enable_user_metric_persistent开启时,才会定期将视图PG_TOTAL_USER_RESOURCE_INFO中的数据保存到历史表中。

    所查各字段说明详见GS_WLM_USER_RESOURCE_HISTORY

support.huaweicloud.com/devg-dws/dws_04_0394.html