forked from docs/doc-exports
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>
157 lines
36 KiB
HTML
157 lines
36 KiB
HTML
<a name="EN-US_TOPIC_0000001099134588"></a><a name="EN-US_TOPIC_0000001099134588"></a>
|
|
|
|
<h1 class="topictitle1">Historical TopSQL</h1>
|
|
<div id="body1500282066544"><p id="EN-US_TOPIC_0000001099134588__p7863164612376">You can query historical Top SQL in historical resource monitoring views. The historical resource monitoring view records the resource usage (of memory, disk, CPU time, and I/O), running status (including errors, termination, and exceptions), and performance alarm information during job running. For queries that abnormally terminate due to FATAL or PANIC errors, their status is displayed as <strong id="EN-US_TOPIC_0000001099134588__b842352706163537">aborted</strong> and no detailed information is recorded. Status information about query parsing in the optimization phase cannot be monitored.</p>
|
|
<p id="EN-US_TOPIC_0000001099134588__p1926013415223">The following table describes the external interfaces of the historical views.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001099134588__table16116143418462" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001099134588__row2269163474610"><th align="left" class="cellrowborder" valign="top" id="mcps1.3.3.1.5.1.1"><p id="EN-US_TOPIC_0000001099134588__p8269434174616">Level</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" id="mcps1.3.3.1.5.1.2"><p id="EN-US_TOPIC_0000001099134588__p1926911343463">Monitored Node</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" colspan="2" valign="top" id="mcps1.3.3.1.5.1.3"><p id="EN-US_TOPIC_0000001099134588__p122696344466">View</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="EN-US_TOPIC_0000001099134588__row15269134174618"><td class="cellrowborder" rowspan="4" valign="top" width="14.430000000000001%" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p17165121416187">Query level/perf level</p>
|
|
</td>
|
|
<td class="cellrowborder" rowspan="2" valign="top" width="14.430000000000001%" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p385934402014">Current CN</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.57%" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001099134588__p727014342461">History (Database Manager interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.57%" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001099134588__p8270163474615"><a href="dws_04_0705.html">GS_WLM_SESSION_HISTORY</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row15270123412464"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p19270113416460">History (internal dump interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p427019342464"><a href="dws_04_0704.html">GS_WLM_SESSION_INFO</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row2270113412467"><td class="cellrowborder" rowspan="2" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p3794195252011">All CNs</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p027017348469">History (Database Manager interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001099134588__p1427113346469"><a href="dws_04_0840.html">PGXC_WLM_SESSION_HISTORY</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row11271534194614"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p1527111343469">History (internal dump interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p4271133444611"><a href="dws_04_0839.html">PGXC_WLM_SESSION_INFO</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row142711834144613"><td class="cellrowborder" rowspan="4" valign="top" width="14.430000000000001%" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p5641135816206">Operator</p>
|
|
</td>
|
|
<td class="cellrowborder" rowspan="2" valign="top" width="14.430000000000001%" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p1064185814207">Current CN</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.57%" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001099134588__p727117344462">History (Database Manager interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="35.57%" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001099134588__p12271203415461"><a href="dws_04_0702.html">GS_WLM_OPERATOR_HISTORY</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row6271234184616"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p18271934114610">History (internal dump interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p6271334144617"><a href="dws_04_0701.html">GS_WLM_OPERAROR_INFO</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row1227193424614"><td class="cellrowborder" rowspan="2" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p1644106102115">All CNs</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p1327133418468">History (Database Manager interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001099134588__p16271123411461"><a href="dws_04_0836.html">PGXC_WLM_OPERATOR_HISTORY</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="EN-US_TOPIC_0000001099134588__row62710347467"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001099134588__p92711734144617">History (internal dump interface)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001099134588__p727113346465"><a href="dws_04_0837.html">PGXC_WLM_OPERATOR_INFO</a></p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note" id="EN-US_TOPIC_0000001099134588__n7a9652a1f8594abf8cd88b657df7f214"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001099134588__ul12931465406"><li id="EN-US_TOPIC_0000001099134588__li13474165412533">The view level is determined by the resource monitoring level, that is, the <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section153571329142612">resource_track_level</a> configuration.</li><li id="EN-US_TOPIC_0000001099134588__li16210812192213">The perf and operator levels affect the values of the <strong id="EN-US_TOPIC_0000001099134588__b41981618192813">query_plan</strong> and <strong id="EN-US_TOPIC_0000001099134588__b10198318152815">warning</strong> columns in <a href="dws_04_0706.html">GS_WLM_SESSION_STATISTICS</a>/<a href="dws_04_0839.html">PGXC_WLM_SESSION_INFO</a>. For details, see <a href="dws_04_0446.html">SQL Self-Diagnosis</a>.</li><li id="EN-US_TOPIC_0000001099134588__li1094246194016">Prefixes <strong id="EN-US_TOPIC_0000001099134588__b147861146156">gs</strong> and <strong id="EN-US_TOPIC_0000001099134588__b1278624141520">pgxc</strong> indicate views showing single CN information and those showing cluster information, respectively. Common users can log in to a CN in the cluster to query only views with the <strong id="EN-US_TOPIC_0000001099134588__b09977810154">gs</strong> prefix.</li><li id="EN-US_TOPIC_0000001099134588__li1294164634014">You can query the <strong id="EN-US_TOPIC_0000001099134588__b244024114515">gs_wlm_session_info</strong>, <strong id="EN-US_TOPIC_0000001099134588__b12492024124517">gs_wlm_operator_info</strong>, <strong id="EN-US_TOPIC_0000001099134588__b349172474515">pgxc_wlm_session_info</strong>, and <strong id="EN-US_TOPIC_0000001099134588__b8499245453">pgxc_wlm_operator_info</strong> views only after connecting to the <strong id="EN-US_TOPIC_0000001099134588__b43231144133218"></strong><strong id="EN-US_TOPIC_0000001099134588__b8323194420324"><span id="EN-US_TOPIC_0000001099134588__ph1583963816503">gaussdb</span></strong> database.</li><li id="EN-US_TOPIC_0000001099134588__li59415465406">If instance fault occurs, some SQL statement information may fail to be recorded in historical resource monitoring views.</li><li id="EN-US_TOPIC_0000001099134588__li1714310361278">In some abnormal cases, the status information column in the historical TopSQL may be displayed as <strong id="EN-US_TOPIC_0000001099134588__b1182527152713">unknown</strong>. The recorded monitoring information may be inaccurate.</li><li id="EN-US_TOPIC_0000001099134588__li63372482446">The SQL statements that can be recorded in historical resource monitoring views are the same as those recorded in real-time resource monitoring views. For details, see <a href="dws_04_0397.html#EN-US_TOPIC_0000001098974816__li12942257154712">SQL statements recorded in real-time resource monitoring views</a>.</li></ul>
|
|
</div></div>
|
|
<div class="section" id="EN-US_TOPIC_0000001099134588__s3c059b5b05dd4bebba57605ec8476f1b"><h4 class="sectiontitle">Prerequisites</h4><ul id="EN-US_TOPIC_0000001099134588__u6076a0db22fd45cf953493a79d391e59"><li id="EN-US_TOPIC_0000001099134588__laa8cf480ef7849e8aa2f1857ab8696dd">The GUC parameter <span id="EN-US_TOPIC_0000001099134588__ph191493139377">enable_resource_track</span> is set to <strong id="EN-US_TOPIC_0000001099134588__b41491137377">on</strong>. The default value is <strong id="EN-US_TOPIC_0000001099134588__b41506135373">on</strong>.</li><li id="EN-US_TOPIC_0000001099134588__li16371944105314">The GUC parameter <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001099134588__b16542058203615">query</strong>, <strong id="EN-US_TOPIC_0000001099134588__b1254275813367">perf</strong>, or <strong id="EN-US_TOPIC_0000001099134588__b8542158103615">operator</strong>. The default value is <strong id="EN-US_TOPIC_0000001099134588__b354215813617">query</strong>. For details, see <a href="dws_04_0397.html#EN-US_TOPIC_0000001098974816__table874434715481">Table 2</a>.</li><li id="EN-US_TOPIC_0000001099134588__l4975437a8a7c4b15b26bf01bc384631f">The GUC parameter <span id="EN-US_TOPIC_0000001099134588__ph59442263017">enable_resource_record</span> is set to <span class="parmvalue" id="EN-US_TOPIC_0000001099134588__parmvalue1120321603715"><b>on</b></span>. The default value is <strong id="EN-US_TOPIC_0000001099134588__b4203716193711">off</strong>.</li><li id="EN-US_TOPIC_0000001099134588__li1235581018551">The value of the <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section347574425112">resource_track_duration</a> parameter (<strong id="EN-US_TOPIC_0000001099134588__b1307770062164858">60s</strong> by default) is less than the job execution time.</li><li id="EN-US_TOPIC_0000001099134588__li774512409428">Job monitoring rules are as follows:<ul id="EN-US_TOPIC_0000001099134588__ul17721175018425"><li id="EN-US_TOPIC_0000001099134588__l4006578543744ff985fb7bb239b9459f">Jobs whose execution time recorded in the real-time resource monitoring view (see <a href="dws_04_0397.html#EN-US_TOPIC_0000001098974816__table16116143418462">Table 1</a>) is greater than or equal to <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section347574425112">resource_track_duration</a>.</li></ul>
|
|
</li><li id="EN-US_TOPIC_0000001099134588__l7a3a85df0fb34cde8108e3f5c8ca6c48">If the Cgroups function is properly loaded, you can run the <strong id="EN-US_TOPIC_0000001099134588__b1268014288479">gs_cgroup -P</strong> command to view information about Cgroups.</li><li id="EN-US_TOPIC_0000001099134588__li5787332589">This function will cause storage space expansion and slightly affect system performance. You are not advised to set it as a default system function.</li></ul>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001099134588__sf74c4e3849684455b8bdb513fe44153d"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0000001099134588__o484ff66141cc45339e715330151ca368"><li id="EN-US_TOPIC_0000001099134588__li41091322194215"><span>Query the load records of the current CN after its latest job is complete in the <strong id="EN-US_TOPIC_0000001099134588__b1996442636165442">gs_wlm_session_history</strong> view.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen171108227421"><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_session_history</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__li17295131115432"><span>Query the load records of all the CNs after their latest job are complete in the <strong id="EN-US_TOPIC_0000001099134588__b486383449">pgxc_wlm_session_history</strong> view.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen10295211144313"><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="w"> </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">pgxc_wlm_session_history</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__lc2f30b2e9de54f8d8049fe3a294cbdc4"><span>Query the load records of the current CN through the <strong id="EN-US_TOPIC_0000001099134588__b205481838123219">gs_wlm_session_info</strong> table after the task is complete. To query the historical records successfully, set <span id="EN-US_TOPIC_0000001099134588__ph154412224314">enable_resource_record</span> to <strong id="EN-US_TOPIC_0000001099134588__b1841271114388">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__s099f65ceee3945659e035643d840f8a2"><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_session_info</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001099134588__u7e1eea0451164ed9945c2e271d387873"><li id="EN-US_TOPIC_0000001099134588__l8a736cd1c10046a799db4b1e5088a697">Top 10 queries that consume the most memory (You can specify a query period.)</li></ul>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__sc75f68237c6f4ce1b6af55e5eb993433"><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_session_info</span><span class="w"> </span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">max_peak_memory</span><span class="w"> </span><span class="k">desc</span><span class="w"> </span><span class="k">limit</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span><span class="w"> </span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen118922411417"><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_session_info</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">start_time</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="s1">'2022-05-15 21:00:00'</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">finish_time</span><span class="w"> </span><span class="o"><=</span><span class="s1">'2022-05-15 23:30:00'</span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">max_peak_memory</span><span class="w"> </span><span class="k">desc</span><span class="w"> </span><span class="k">limit</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span><span class="w"> </span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001099134588__u0a39a1aa074248e7878354df0c2bc4f5"><li id="EN-US_TOPIC_0000001099134588__lf8a9701475fb4fa7b7558f4dc9534417">Top 10 queries that consume the most CPU (You can specify a query period.)</li></ul>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__s7462f6d202694b04bac950584563a731"><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_session_info</span><span class="w"> </span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">total_cpu_time</span><span class="w"> </span><span class="k">desc</span><span class="w"> </span><span class="k">limit</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen19705163132211"><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_session_info</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">start_time</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="s1">'2022-05-15 21:00:00'</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">finish_time</span><span class="w"> </span><span class="o"><=</span><span class="s1">'2022-05-15 23:30:00'</span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">total_cpu_time</span><span class="w"> </span><span class="k">desc</span><span class="w"> </span><span class="k">limit</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__en-us_topic_0066854643_li47671568376"><span>Query for the load records of all the CNs after their jobs are complete in the <strong id="EN-US_TOPIC_0000001099134588__b1938262665217">pgxc_wlm_session_info</strong> view. To query the historical records successfully, set <span id="EN-US_TOPIC_0000001099134588__ph394842303817">enable_resource_record</span> to <strong id="EN-US_TOPIC_0000001099134588__b20948323153817">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__s83865760d3d5475bb9ff451092863e84"><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">pgxc_wlm_session_info</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001099134588__ul153931208413"><li id="EN-US_TOPIC_0000001099134588__li1939312204415">Query the top 10 queries that take up the most CN processing time (You can specify a query period.)</li></ul>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen1489165916415"><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">pgxc_wlm_session_info</span><span class="w"> </span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">duration</span><span class="w"> </span><span class="k">desc</span><span class="w"> </span><span class="k">limit</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen18693118165818"><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">pgxc_wlm_session_info</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">start_time</span><span class="w"> </span><span class="o">>=</span><span class="w"> </span><span class="s1">'2022-05-15 21:00:00'</span><span class="w"> </span><span class="k">and</span><span class="w"> </span><span class="n">finish_time</span><span class="w"> </span><span class="o"><=</span><span class="s1">'2022-05-15 23:30:00'</span><span class="k">order</span><span class="w"> </span><span class="k">by</span><span class="w"> </span><span class="n">nodename</span><span class="p">,</span><span class="n">max_peak_memory</span><span class="w"> </span><span class="k">desc</span><span class="w"> </span><span class="k">limit</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__li294548102314"><span>Use the <strong id="EN-US_TOPIC_0000001099134588__b1784710274387">pgxc_get_wlm_session_info_bytime</strong> function to filter and query the <strong id="EN-US_TOPIC_0000001099134588__b1585210279386">pgxc_wlm_session_info</strong> view. To query the historical records successfully, set <span id="EN-US_TOPIC_0000001099134588__ph1645183563114">enable_resource_record</span> to <strong id="EN-US_TOPIC_0000001099134588__b158533272383">on</strong>. You are advised to use this function if the view contains a large number of records.</span><p><div class="note" id="EN-US_TOPIC_0000001099134588__note1331123503116"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001099134588__p18647195773116">A GaussDB(DWS) cluster uses the UTC time by default, which has an 8-hour time difference with the system time. Before queries, ensure that the database time is the same as the system time.</p>
|
|
</div></div>
|
|
<ul id="EN-US_TOPIC_0000001099134588__ul1750342133120"><li id="EN-US_TOPIC_0000001099134588__li950322112316">Return the queries started between <strong id="EN-US_TOPIC_0000001099134588__b10197307539">2019-09-10 15:30:00</strong> and <strong id="EN-US_TOPIC_0000001099134588__b04091951205315">2019-09-10 15:35:00</strong> on all CNs. For each CN, a maximum of 10 queries will be returned.</li></ul>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen55034215311"><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">pgxc_get_wlm_session_info_bytime</span><span class="p">(</span><span class="s1">'start_time'</span><span class="p">,</span><span class="w"> </span><span class="s1">'2019-09-10 15:30:00'</span><span class="p">,</span><span class="w"> </span><span class="s1">'2019-09-10 15:35:00'</span><span class="p">,</span><span class="w"> </span><span class="mi">10</span><span class="p">);</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
<ul id="EN-US_TOPIC_0000001099134588__ul6535142964510"><li id="EN-US_TOPIC_0000001099134588__li1535529194515">Return the queries ended between <strong id="EN-US_TOPIC_0000001099134588__b4772132314586">2019-09-10 15:30:00</strong> and <strong id="EN-US_TOPIC_0000001099134588__b8774132316588">2019-09-10 15:35:00</strong> on all CNs. For each CN, a maximum of 10 queries will be returned.</li></ul>
|
|
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen165800904518"><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">pgxc_get_wlm_session_info_bytime</span><span class="p">(</span><span class="s1">'finish_time'</span><span class="p">,</span><span class="w"> </span><span class="s1">'2019-09-10 15:30:00'</span><span class="p">,</span><span class="w"> </span><span class="s1">'2019-09-10 15:35:00'</span><span class="p">,</span><span class="w"> </span><span class="mi">10</span><span class="p">);</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__li1011051711292"><span>Query the recent resource information of the job operators on the current CN in the <strong id="EN-US_TOPIC_0000001099134588__b177612960162722">gs_wlm_operator_history</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001099134588__en-us_topic_0058967547_b8423527061695">operator</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen41101617172918"><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_operator_history</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__li175856393329"><span>Query the recent resource information of the job operators on all the CNs in the <strong id="EN-US_TOPIC_0000001099134588__b293841469">pgxc_wlm_operator_history</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001099134588__b177240199">operator</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen11586143918322"><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">pgxc_wlm_operator_history</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__li10817527102115"><span>Query the recent resource information of the job operators on the current CN in the <strong id="EN-US_TOPIC_0000001099134588__b842352706165733">gs_wlm_operator_info</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001099134588__b1316415319384">operator</strong> and <span id="EN-US_TOPIC_0000001099134588__ph31631342113114">enable_resource_record</span> to <strong id="EN-US_TOPIC_0000001099134588__b141641953183819">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen681815271213"><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_operator_info</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li><li id="EN-US_TOPIC_0000001099134588__li48211027102110"><span>Query for the historical resource information of job operators on all the CNs in the <strong id="EN-US_TOPIC_0000001099134588__b11344144135219">pgxc_wlm_operator_info</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001099134588__b1643601793910">operator</strong> and <span id="EN-US_TOPIC_0000001099134588__ph343611175396">enable_resource_record</span> to <strong id="EN-US_TOPIC_0000001099134588__b64371117163915">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001099134588__screen10821327162116"><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">pgxc_wlm_operator_info</span><span class="p">;</span><span class="w"></span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</p></li></ol>
|
|
<div class="note" id="EN-US_TOPIC_0000001099134588__note1514925216314"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001099134588__ul2515175332318"><li id="EN-US_TOPIC_0000001099134588__li1515653202314">The number of data records that can be retained in the memory is limited, because certain memory is reserved. After a real-time query is complete, its information is imported to historical views and will be deleted when the information has been stored in the hash table in the memory for 3 minutes. The upper limit of records varies by view. For a query-level view, whether a record can be stored depends on the upper limit of records allowed by the memory at that time point. On each CN, the maximum number of real-time query-level records that can be stored in memory (default: <strong id="EN-US_TOPIC_0000001099134588__b69991417143317">5MB</strong>) is <strong id="EN-US_TOPIC_0000001099134588__b10171853315">max_session_realt_num</strong> (set to <strong id="EN-US_TOPIC_0000001099134588__b3171893314">12850</strong> by default). The maximum number of historical records that can be stored in memory (default: <strong id="EN-US_TOPIC_0000001099134588__b7171817331">100MB</strong>) is <strong id="EN-US_TOPIC_0000001099134588__b202918173315">max_session_hist_num</strong> (set to <strong id="EN-US_TOPIC_0000001099134588__b13351823317">137970</strong> by default). The average execution time of queries in a service system is greater than <strong id="EN-US_TOPIC_0000001099134588__b16411893311">run_time</strong> (in the unit of s). The maximum number of concurrent jobs allowed by real-time views on each CN is: <strong id="EN-US_TOPIC_0000001099134588__b0518185338">num_realt_active</strong> = <strong id="EN-US_TOPIC_0000001099134588__b1514185335">max_session_realt_num</strong>. The maximum number of concurrent jobs allowed by historical views on each CN is: <strong id="EN-US_TOPIC_0000001099134588__b660184337">num_hist_active</strong> = <strong id="EN-US_TOPIC_0000001099134588__b771118163318">max_session_hist_num</strong>/(<strong id="EN-US_TOPIC_0000001099134588__b577181339">180</strong>/<strong id="EN-US_TOPIC_0000001099134588__b181718123315">run_time</strong>).</li><li id="EN-US_TOPIC_0000001099134588__li114068515249">For operator-level views, whether a record can be stored depends on the upper limit allowed by the memory at that time point. If the number of plan nodes plus the number of records in the memory exceeds the upper limit, the record cannot be stored. On each CN, the maximum numbers of real-time and historical operator-level records that can be stored in the memory are <strong id="EN-US_TOPIC_0000001099134588__b1488733512350">max_oper_realt_num</strong> (set to <strong id="EN-US_TOPIC_0000001099134588__b8888173593514">56987</strong> by default) and <strong id="EN-US_TOPIC_0000001099134588__b10889235153510">max_oper_hist_num</strong> (set to <strong id="EN-US_TOPIC_0000001099134588__b14890735193517">113975</strong> by default), respectively. The average number of plan nodes of a query is <strong id="EN-US_TOPIC_0000001099134588__b198911935193516">num_plan_node</strong>. Maximum number of concurrent tasks allowed by real-time views on each CN is: <strong id="EN-US_TOPIC_0000001099134588__b178911535103511">num_realt_active</strong> = <strong id="EN-US_TOPIC_0000001099134588__b78921335113511">max_oper_realt_num</strong>/<strong id="EN-US_TOPIC_0000001099134588__b4893335203514">num_plan_node</strong>. Maximum number of concurrent tasks allowed by historical views on each CN is: <strong id="EN-US_TOPIC_0000001099134588__b489310354351">num_hist_active</strong> = <strong id="EN-US_TOPIC_0000001099134588__b989373516352">max_oper_hist_num</strong>/(<strong id="EN-US_TOPIC_0000001099134588__b108941435103519">180</strong>/<strong id="EN-US_TOPIC_0000001099134588__b17894735163511">run_time</strong>)/<strong id="EN-US_TOPIC_0000001099134588__b5895103519351">num_plan_node</strong>.</li><li id="EN-US_TOPIC_0000001099134588__li4607911142919">In high concurrency, ensure that the number of queries to be recorded does not exceed the maximum values set for query- and operator-level queries. You can modify the memory of the real-time query view by setting <a href="dws_04_0922.html#EN-US_TOPIC_0000001145694507__section4520191223820">session_statistics_memory</a> and the memory of the historical query view by setting <strong id="EN-US_TOPIC_0000001099134588__b8489294332">session_history_memory</strong>. The memory size increases in direct proportion to the maximum number of queries that can be recorded.</li></ul>
|
|
</div></div>
|
|
</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>
|
|
|