doc-exports/docs/dws/dev/dws_04_0394.html
Lu, Huayi a24ca60074 DWS DEVELOPER 811 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2023-01-19 13:37:49 +00:00

63 lines
13 KiB
HTML

<a name="EN-US_TOPIC_0000001147419403"></a><a name="EN-US_TOPIC_0000001147419403"></a>
<h1 class="topictitle1">User Resource Query</h1>
<div id="body0000001147419403"><div class="section" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_sa79b4efe5d9c4fd388d2580476198563"><h4 class="sectiontitle">Context</h4><p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_ab7a2234c948342cbb38eb4abd101dc13">In the multi-tenant management framework, you can query the real-time or historical usage of all user resources (including memory, CPU cores, storage space, temporary space, and I/Os).</p>
<div class="note" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_n7a9652a1f8594abf8cd88b657df7f214"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_ul2046120281910"><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li1340193311018">User real-time resource views/functions: <a href="dws_04_0790.html">PG_TOTAL_USER_RESOURCE_INFO</a> and GS_WLM_USER_RESOURCE_INFO; user historical resource table: <a href="dws_04_0567.html">GS_WLM_USER_RESOURCE_HISTORY</a>.</li><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li383120481562">In the preceding views and tables, the value of <strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b4450857175410">used_cpu</strong> indicates the CPU usage of a user's resource pool. The resource pool records only the CPU usage of long queries.</li><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li115211392911">In the preceding views and tables, I/O-related resource statistics only record I/O read and write data of long queries executed by users.</li><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li9397175161910">When there are a large number of users and a large cluster, querying such real-time views will cause network latency due to the real-time communication overhead between CNs and DNs.</li><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li164661042143714">User memory and CPU monitoring does not apply to short queries or administrator jobs.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_s94c9533698194ccdad198448439a9aa4"><h4 class="sectiontitle">Procedure</h4><ul id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_ul11778104193915"><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li1177811433911">Query all users' resource quotas and real-time resource usage.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_sd8c93121e8bc4d41bc15666d44477a5f"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">PG_TOTAL_USER_RESOURCE_INFO</span><span class="p">;</span><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_a22a51664352e4867951ae2fb0e745c21">The result view is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_screen1669016192413">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 | 17250 | 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)</pre>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_p2214132131818">The I/O resource monitoring fields (<strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b13223553104610">read_kbytes</strong>, <strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b5224853184614">write_kbytes</strong>, <strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b322405315468">read_counts</strong>, <strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b1622413537466">write_counts</strong>, <strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b17224453184611">read_speed</strong>, and <strong id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_b2224353184619">write_speed</strong>) can be available only when the GUC parameter enable_user_metric_persistent is enabled.</p>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_a1b0b7782d4b24c18834dc68ed177bf2e">For details about each column, see <a href="dws_04_0790.html">PG_TOTAL_USER_RESOURCE_INFO</a>.</p>
</li></ul>
<ul id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_ul440710812393"><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li134070833918">Query a user's resource quota and real-time resource usage.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_s585ab541b93a48fcb72f4139c2ca5ed3"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">GS_WLM_USER_RESOURCE_INFO</span><span class="p">(</span><span class="s1">'username'</span><span class="p">);</span><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_p17368833105817">The query result is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_screen16553102284">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)</pre>
</li></ul>
<ul id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_ul10174171303915"><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li13369339153613">Query all users' resource quotas and historical resource usage.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_screen15593124715419"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">GS_WLM_USER_RESOURCE_HISTORY</span><span class="p">;</span><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_p1832531563713">The query result is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_screen1986417472284">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</pre>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_p873752710298">For the system catalog in <a href="dws_04_0567.html">GS_WLM_USER_RESOURCE_HISTORY</a>, data in the <a href="dws_04_0790.html">PG_TOTAL_USER_RESOURCE_INFO</a> view is periodically saved to historical tables only when the GUC parameter <span id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_ph867873711231">enable_user_metric_persistent</span> is enabled.</p>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_p051610447443">For details about each column, see <a href="dws_04_0567.html">GS_WLM_USER_RESOURCE_HISTORY</a>.</p>
</li><li id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_li0174181353920">Query the real-time I/O control resource usage of a specific user. (The value in the view indicates the I/O control resource usage instead of the actual I/O read/write data.)<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_screen20898105132515"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">pg_user_iostat</span><span class="p">(</span><span class="s1">'username'</span><span class="p">);</span><span class="w"></span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_p1741418536245">The query result is as follows:</p>
<pre class="screen" id="EN-US_TOPIC_0000001147419403__en-us_topic_0000001145495049_screen17784679269"> userid | min_curr_iops | max_curr_iops | min_peak_iops | max_peak_iops | io_limits | io_priority
-------+---------------+---------------+---------------+---------------+-----------+-------------
10 | 0 | 0 | 0 | 0 | 0 | None
(1 row)</pre>
</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0393.html">Resource Monitoring</a></div>
</div>
</div>