doc-exports/docs/dws/dev/dws_04_0398.html
Lu, Huayi e6fa411af0 DWS DEV 830.201 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2024-05-16 07:24:04 +00:00

161 lines
35 KiB
HTML

<a name="EN-US_TOPIC_0000001233761849"></a><a name="EN-US_TOPIC_0000001233761849"></a>
<h1 class="topictitle1">Historical Top SQL</h1>
<div id="body1500282066544"><p id="EN-US_TOPIC_0000001233761849__p7863164612376">You can query historical Top SQL in historical resource monitoring views. The historical resource monitoring view records the resource usage (including memory, data spilled to disks, and CPU time), running status (including errors, termination, and exceptions), and performance alarm information when a job is complete. For queries that abnormally terminate due to FATAL or PANIC errors, their status is displayed as <strong id="EN-US_TOPIC_0000001233761849__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_0000001233761849__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_0000001233761849__table16116143418462" frame="border" border="1" rules="all"><thead align="left"><tr id="EN-US_TOPIC_0000001233761849__row2269163474610"><th align="left" class="cellrowborder" valign="top" id="mcps1.3.3.1.5.1.1"><p id="EN-US_TOPIC_0000001233761849__p8269434174616">Level</p>
</th>
<th align="left" class="cellrowborder" valign="top" id="mcps1.3.3.1.5.1.2"><p id="EN-US_TOPIC_0000001233761849__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_0000001233761849__p122696344466">View</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001233761849__row15269134174618"><td class="cellrowborder" rowspan="4" valign="top" width="14.430000000000001%" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p102691034154612">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_0000001233761849__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_0000001233761849__p727014342461">History (Internal dump interface. Only statements that have ended in the last three minutes are displayed.)</p>
</td>
<td class="cellrowborder" valign="top" width="35.57%" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001233761849__p8270163474615"><a href="dws_04_0705.html">GS_WLM_SESSION_HISTORY</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row15270123412464"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p19270113416460">History (all statements)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001233761849__p427019342464"><a href="dws_04_0704.html">GS_WLM_SESSION_INFO</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row2270113412467"><td class="cellrowborder" rowspan="2" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p3794195252011">All CNs</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001233761849__p027017348469">History (Internal dump interface. Only statements that have ended in the last three minutes are displayed.)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001233761849__p1427113346469"><a href="dws_04_0840.html">PGXC_WLM_SESSION_HISTORY</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row11271534194614"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p1527111343469">History (all statements)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001233761849__p4271133444611"><a href="dws_04_0839.html">PGXC_WLM_SESSION_INFO</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row142711834144613"><td class="cellrowborder" rowspan="4" valign="top" width="14.430000000000001%" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p5641135816206">Operator 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_0000001233761849__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_0000001233761849__p727117344462">History (Only statements that have ended in the last three minutes are displayed.)</p>
</td>
<td class="cellrowborder" valign="top" width="35.57%" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001233761849__p12271203415461"><a href="dws_04_0702.html">GS_WLM_OPERATOR_HISTORY</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row6271234184616"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p18271934114610">History (internal dump interface, all statements)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001233761849__p6271334144617"><a href="dws_04_0701.html">GS_WLM_OPERAROR_INFO</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row1227193424614"><td class="cellrowborder" rowspan="2" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p1644106102115">All CNs</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001233761849__p1327133418468">History (Only statements that have ended in the last three minutes are displayed.)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.3 "><p id="EN-US_TOPIC_0000001233761849__p16271123411461"><a href="dws_04_0836.html">PGXC_WLM_OPERATOR_HISTORY</a></p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001233761849__row62710347467"><td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.1 "><p id="EN-US_TOPIC_0000001233761849__p92711734144617">History (internal dump interface, all statements)</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.3.3.1.5.1.2 "><p id="EN-US_TOPIC_0000001233761849__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_0000001233761849__n7a9652a1f8594abf8cd88b657df7f214"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001233761849__ul12931465406"><li id="EN-US_TOPIC_0000001233761849__li18350825114219">The view level is determined by the resource monitoring level, that is, the <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section153571329142612">resource_track_level</a> configuration.</li><li id="EN-US_TOPIC_0000001233761849__li541810241581">The perf and operator levels affect the values of the <strong id="EN-US_TOPIC_0000001233761849__b6363553142518">query_plan</strong> and <strong id="EN-US_TOPIC_0000001233761849__b17363145317259">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_0000001233761849__li1094246194016">Prefixes <strong id="EN-US_TOPIC_0000001233761849__b147861146156">gs</strong> and <strong id="EN-US_TOPIC_0000001233761849__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_0000001233761849__b09977810154">gs</strong> prefix.</li><li id="EN-US_TOPIC_0000001233761849__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_0000001233761849__li1714310361278">In some abnormal cases, the status information column in the historical Top SQL may be displayed as <strong id="EN-US_TOPIC_0000001233761849__b1182527152713">unknown</strong>. The recorded monitoring information may be inaccurate.</li><li id="EN-US_TOPIC_0000001233761849__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_0000001233681601__li12942257154712">SQL statements recorded in real-time resource monitoring views</a>.</li><li id="EN-US_TOPIC_0000001233761849__li11949249165517">Historical Top SQL records data only when the GUC parameter <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> is enabled.</li><li id="EN-US_TOPIC_0000001233761849__li076442713561">You can query historical Top SQL queries and operator-level data only through the PostgreSQL database.</li><li id="EN-US_TOPIC_0000001233761849__li4960193712610">Historical Top SQL focuses on locating and demarcating query performance problems. It is not used for auditing or recording syntax analysis error statements.</li></ul>
</div></div>
<div class="section" id="EN-US_TOPIC_0000001233761849__s3c059b5b05dd4bebba57605ec8476f1b"><h4 class="sectiontitle">Prerequisites</h4><ul id="EN-US_TOPIC_0000001233761849__u6076a0db22fd45cf953493a79d391e59"><li id="EN-US_TOPIC_0000001233761849__laa8cf480ef7849e8aa2f1857ab8696dd">The GUC parameter <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s9530ecdd2b0d4a98b67b66e32bf8e5d0">enable_resource_track</a> is set to <strong id="EN-US_TOPIC_0000001233761849__b1458310551666">on</strong>. The default value is <strong id="EN-US_TOPIC_0000001233761849__b1158412551618">on</strong>.</li><li id="EN-US_TOPIC_0000001233761849__li16371944105314">The GUC parameter <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001233761849__b16542058203615">query</strong>, <strong id="EN-US_TOPIC_0000001233761849__b1254275813367">perf</strong>, or <strong id="EN-US_TOPIC_0000001233761849__b8542158103615">operator</strong>. The default value is <strong id="EN-US_TOPIC_0000001233761849__b354215813617">query</strong>. For details, see <a href="dws_04_0397.html#EN-US_TOPIC_0000001233681601__table874434715481">Table 2</a>.</li><li id="EN-US_TOPIC_0000001233761849__l4975437a8a7c4b15b26bf01bc384631f">The GUC parameter <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> is set to <span class="parmvalue" id="EN-US_TOPIC_0000001233761849__parmvalue1120321603715"><b>on</b></span>. The default value is <strong id="EN-US_TOPIC_0000001233761849__b4203716193711">on</strong>.</li><li id="EN-US_TOPIC_0000001233761849__li1235581018551">The value of the <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section347574425112">resource_track_duration</a> parameter (<strong id="EN-US_TOPIC_0000001233761849__b1307770062164858">60s</strong> by default) is less than the job execution time.</li><li id="EN-US_TOPIC_0000001233761849__li1745162845818">The GUC parameter <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section7181949101319">enable_track_record_subsql</a> specifies whether to record internal statements of a stored procedure or anonymous block. The default value is <strong id="EN-US_TOPIC_0000001233761849__b1620055210314">off</strong>.</li><li id="EN-US_TOPIC_0000001233761849__li774512409428">Jobs whose execution time recorded in the real-time resource monitoring view (see <a href="dws_04_0397.html#EN-US_TOPIC_0000001233681601__table16116143418462">Table 1</a>) is greater than or equal to <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section347574425112">resource_track_duration</a> are monitored.</li><li id="EN-US_TOPIC_0000001233761849__l7a3a85df0fb34cde8108e3f5c8ca6c48">If the Cgroups function is properly loaded, you can run the <strong id="EN-US_TOPIC_0000001233761849__b1268014288479">gs_cgroup -P</strong> command to view information about Cgroups.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001233761849__sf74c4e3849684455b8bdb513fe44153d"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0000001233761849__o484ff66141cc45339e715330151ca368"><li id="EN-US_TOPIC_0000001233761849__li41091322194215"><span>Query the load records of the current CN after its latest job is complete in the <strong id="EN-US_TOPIC_0000001233761849__b1996442636165442">gs_wlm_session_history</strong> view.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__li17295131115432"><span>Query the load records of all the CNs after their latest job are complete in the <strong id="EN-US_TOPIC_0000001233761849__b1394409643">pgxc_wlm_session_history</strong> view.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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="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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__lc2f30b2e9de54f8d8049fe3a294cbdc4"><span>Query the load records of the current CN through the <strong id="EN-US_TOPIC_0000001233761849__b205481838123219">gs_wlm_session_info</strong> table after the task is complete. To query the historical records successfully, set <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> to <strong id="EN-US_TOPIC_0000001233761849__b1841271114388">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
<ul id="EN-US_TOPIC_0000001233761849__u7e1eea0451164ed9945c2e271d387873"><li id="EN-US_TOPIC_0000001233761849__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_0000001233761849__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_0000001233761849__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">&gt;=</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">&lt;=</span><span class="s1">'2022-05-15 23:30:00'</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>
<ul id="EN-US_TOPIC_0000001233761849__u0a39a1aa074248e7878354df0c2bc4f5"><li id="EN-US_TOPIC_0000001233761849__lf8a9701475fb4fa7b7558f4dc9534417">Showing the 10 queries consuming the most CPU resources:</li></ul>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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">&gt;=</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">&lt;=</span><span class="s1">'2022-05-15 23:30:00'</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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__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_0000001233761849__b1938262665217">pgxc_wlm_session_info</strong> view. To query the historical records successfully, set <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> to <strong id="EN-US_TOPIC_0000001233761849__b20948323153817">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
<ul id="EN-US_TOPIC_0000001233761849__ul153931208413"><li id="EN-US_TOPIC_0000001233761849__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_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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">&gt;=</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">&lt;=</span><span class="s1">'2022-05-15 23:30:00'</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">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>
</pre></div></td></tr></table></div>
</div>
<ul id="EN-US_TOPIC_0000001233761849__ul56258225129"><li id="EN-US_TOPIC_0000001233761849__li146251222141219">Queries the execution information about a query statement that has been executed. For example, query the execution information about the statement whose <strong id="EN-US_TOPIC_0000001233761849__b1353510983513">queryid</strong> is <strong id="EN-US_TOPIC_0000001233761849__b7890461356">76561193695026478</strong>.</li></ul>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__screen143621558131318"><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">queryid</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'76561193695026478'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__li294548102314"><span>Use the <strong id="EN-US_TOPIC_0000001233761849__b1784710274387">pgxc_get_wlm_session_info_bytime</strong> function to filter and query the <strong id="EN-US_TOPIC_0000001233761849__b1585210279386">pgxc_wlm_session_info</strong> view. To query the historical records successfully, set <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> to <strong id="EN-US_TOPIC_0000001233761849__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_0000001233761849__note23535177453"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001233761849__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_0000001233761849__ul1750342133120"><li id="EN-US_TOPIC_0000001233761849__li950322112316">Return the queries started between <strong id="EN-US_TOPIC_0000001233761849__b10197307539">2019-09-10 15:30:00</strong> and <strong id="EN-US_TOPIC_0000001233761849__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_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
<ul id="EN-US_TOPIC_0000001233761849__ul6535142964510"><li id="EN-US_TOPIC_0000001233761849__li1535529194515">Return the queries ended between <strong id="EN-US_TOPIC_0000001233761849__b4772132314586">2019-09-10 15:30:00</strong> and <strong id="EN-US_TOPIC_0000001233761849__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_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__li1011051711292"><span>Query the recent resource information of the job operators on the current CN in the <strong id="EN-US_TOPIC_0000001233761849__b177612960162722">gs_wlm_operator_history</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001233761849__en-us_topic_0058967547_b8423527061695">operator</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__li175856393329"><span>Query the recent resource information of the job operators on all the CNs in the <strong id="EN-US_TOPIC_0000001233761849__b840650593">pgxc_wlm_operator_history</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001233761849__b108358289">operator</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__li10817527102115"><span>Query the recent resource information of the job operators on the current CN in the <strong id="EN-US_TOPIC_0000001233761849__b842352706165733">gs_wlm_operator_info</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001233761849__b1316415319384">operator</strong> and <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> to <strong id="EN-US_TOPIC_0000001233761849__b141641953183819">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
</p></li><li id="EN-US_TOPIC_0000001233761849__li48211027102110"><span>Query for the historical resource information of job operators on all the CNs in the <strong id="EN-US_TOPIC_0000001233761849__b11344144135219">pgxc_wlm_operator_info</strong> view. Ensure that <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section153571329142612">resource_track_level</a> is set to <strong id="EN-US_TOPIC_0000001233761849__b9515674513">operator</strong> and <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__s5f116e109a2944e3854abcc56772eaa1">enable_resource_record</a> to <strong id="EN-US_TOPIC_0000001233761849__b3511769453">on</strong>.</span><p><div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001233761849__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>
</pre></div></td></tr></table></div>
</div>
</p></li></ol>
<div class="note" id="EN-US_TOPIC_0000001233761849__note1514925216314"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001233761849__ul2515175332318"><li id="EN-US_TOPIC_0000001233761849__li1515653202314">The number of data records that can be retained in the memory is limited due to the preset memory limit. After the real-time query is complete, the data records are imported to historical views. For a query-level view, when the number of queries to be recorded exceeds the upper limit allowed by the memory, the current query cannot be recorded and the next query is performed based on a new rule. On each CN, the memory usage of the query-level historical view is recorded (100 MB by default). You can query the data in the <a href="dws_04_0788.html">PG_TOTAL_MEMORY_DETAIL</a> view.</li><li id="EN-US_TOPIC_0000001233761849__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_0000001233761849__b1488733512350">max_oper_realt_num</strong> (set to <strong id="EN-US_TOPIC_0000001233761849__b8888173593514">56987</strong> by default) and <strong id="EN-US_TOPIC_0000001233761849__b10889235153510">max_oper_hist_num</strong> (set to <strong id="EN-US_TOPIC_0000001233761849__b14890735193517">113975</strong> by default), respectively. The average number of plan nodes of a query is <strong id="EN-US_TOPIC_0000001233761849__b198911935193516">num_plan_node</strong>. Maximum number of concurrent tasks allowed by real-time views on each CN is: <strong id="EN-US_TOPIC_0000001233761849__b178911535103511">num_realt_active</strong> = <strong id="EN-US_TOPIC_0000001233761849__b78921335113511">max_oper_realt_num</strong>/<strong id="EN-US_TOPIC_0000001233761849__b4893335203514">num_plan_node</strong>. Maximum number of concurrent tasks allowed by historical views on each CN is: <strong id="EN-US_TOPIC_0000001233761849__b489310354351">num_hist_active</strong> = <strong id="EN-US_TOPIC_0000001233761849__b989373516352">max_oper_hist_num</strong>/(<strong id="EN-US_TOPIC_0000001233761849__b108941435103519">180</strong>/<strong id="EN-US_TOPIC_0000001233761849__b17894735163511">run_time</strong>)/<strong id="EN-US_TOPIC_0000001233761849__b5895103519351">num_plan_node</strong>.</li><li id="EN-US_TOPIC_0000001233761849__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 views. You can modify the memory of the historical query view by configuring the <a href="dws_04_0922.html#EN-US_TOPIC_0000001233563121__section27306369458">session_history_memory</a> parameter. 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>