Files
doc-exports/docs/dws/dev/dws_04_0126.html
luhuayi 177cd61a57 DWS DEVG 910.211 version
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: luhuayi <luhuayi@huawei.com>
Co-committed-by: luhuayi <luhuayi@huawei.com>
2025-05-05 07:44:03 +00:00

110 lines
24 KiB
HTML

<a name="EN-US_TOPIC_0000002136185113"></a><a name="EN-US_TOPIC_0000002136185113"></a>
<h1 class="topictitle1">SELECT Operation</h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section1749794416463"><h4 class="sectiontitle">Rule 3.7: Avoiding Executing SQL Statements That Do Not Support Pushdown</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note1632120217013"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p4711851123612">GaussDB(DWS) uses a distributed architecture, and to achieve optimal performance, SQL statements need to be pushed down to utilize distributed computing resources.</p>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p3291449204611"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b47739227910741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul18760115410018"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1876013545015">SQL statements that are not pushed down may experience poor execution performance and, in severe cases, can lead to CN resource bottlenecks, impacting overall services.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p1929111496465"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b2112418322112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul449122984813"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1549329184816">Do not use syntax or functions that cannot be executed near the data source. For details, see <a href="dws_04_0447.html">Optimizing Statement Pushdown</a>.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section17685947134614"><h4 class="sectiontitle">Rule 3.8: Specifying Association Conditions when Multiple Tables Are Associated</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note3389113344618"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p129093513472"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b99353987710741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul124472370466"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1744711378464">If no association condition is specified when linking multiple tables, it will result in a Cartesian product calculation. This can lead to an expanded result set, posing risks of performance issues and resource overload.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p544723714618"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1726550733112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul18447153714612"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li54471372461">Specify filter and association conditions for each table during the association process.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section1777795264615"><h4 class="sectiontitle">Rule 3.9: Ensuring Consistency of Data Types in Associated Fields across Multiple Tables</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note1094594512408"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p0188181119536"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b9978355510741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul17374181175517"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1437461115515">Ensure consistent data types for associated fields to avoid unnecessary type conversions, data redistribution issues, and hindered generation of optimal plans.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p191881011155311"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b2047674460112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul1718816115534"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li6189191195315">Use the same data type for associated fields when tables are associated.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section18864134354719"><h4 class="sectiontitle">Suggestion 3.10: Avoiding Function Calculation on Association and Filter Condition Fields</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note1970193220312"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p4744161219585"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b9962822610741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul0744312165820"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li197441412155813">In cases where function calculations are involved in association and filter conditions, the optimizer may fail to obtain accurate field statistics, impacting execution performance.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p197443125589"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b293380120112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul9744121216584"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li187445122584">When comparing association condition fields, preprocess the data before importing it into the database, especially when calculations are required for comparison.</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1046415261245">When filter criteria are compared with constants, perform function calculation only on constant columns. The following is an example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_screen9589174893819"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span>
<span class="normal">5</span>
<span class="normal">6</span>
<span class="normal">7</span>
<span class="normal">8</span>
<span class="normal">9</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">from_image_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_person_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_video_id</span>
<span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span>
<span class="k">WHERE</span><span class="w"> </span><span class="n">SS</span><span class="p">.</span><span class="n">DEL_FLAG</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'N'</span>
<span class="k">AND</span><span class="w"> </span><span class="n">NVL</span><span class="p">(</span><span class="n">SS</span><span class="p">.</span><span class="n">DELETE_FLAG</span><span class="p">,</span><span class="w"> </span><span class="s1">'N'</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'N'</span>
<span class="n">The</span><span class="w"> </span><span class="n">modification</span><span class="w"> </span><span class="k">is</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">follows</span><span class="p">:</span>
<span class="k">SELECT</span><span class="w"> </span><span class="n">id</span><span class="p">,</span><span class="w"> </span><span class="n">from_image_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_person_id</span><span class="p">,</span><span class="w"> </span><span class="n">from_video_id</span>
<span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span>
<span class="k">where</span><span class="w"> </span><span class="n">SS</span><span class="p">.</span><span class="n">DEL_FLAG</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'N'</span>
<span class="k">AND</span><span class="w"> </span><span class="p">(</span><span class="n">SS</span><span class="p">.</span><span class="n">DELETE_FLAG</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'N'</span><span class="w"> </span><span class="k">or</span><span class="w"> </span><span class="n">SS</span><span class="p">.</span><span class="n">DELETE_FLAG</span><span class="w"> </span><span class="k">is</span><span class="w"> </span><span class="k">null</span><span class="p">)</span>
</pre></div></td></tr></table></div>
</div>
</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section152761264813"><h4 class="sectiontitle">Suggestion 3.11: Performing Pressure Tests and Concurrency Control for Resource-intensive SQL Statements</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note272011327556"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p83463509219"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b25480983110741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul18346135013216"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li10346195092114">Storage and computing resources are overloaded, and the overall running performance deteriorates.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p17346155022114"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1736328861112630">Solution:</strong></p>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p917981713229">A resource-intensive SQL statement contains:</p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul10839394241"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li98343913243">A large number of <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b18580151065119">UNION ALL</strong>.</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1583173952416">A large number of AGGs (such as <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b234272365117">COUNT DISTINCT</strong> and <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1640622520513">MAX</strong>).</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li483739182416">A lot of <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b126525412512">JOIN</strong> operations for a large number of tables.</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li584163912416">A large number of <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b172791109524">STREAM</strong> operators (plan dimension).</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p13685340142314">Before rolling out, conduct pressure tests and implement concurrency control for these SQL statements. If the resource capacity is exceeded, optimizing the service should be prioritized before reassessing the rollout plan.</p>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section113151534184817"><h4 class="sectiontitle">Rule 3.12: Avoiding Excessive COUNT Operations on Large Row-store Tables</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note16643200503"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p16995656172915">If SSDs or other high-performance disk types are used, it may not be necessary to adhere strictly to this rule, but it is still crucial to monitor the I/O consumption.</p>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p624225682811"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b23516514310741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul8940618122919"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li6940818122917">Performing frequent <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b8174153617713">COUNT</strong> operations on large row-store tables can consume a significant amount of I/O resources, potentially leading to performance issues if an I/O bottleneck occurs.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p1524225612280"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1259310493112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul14269162242916"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li32691422172919">Reduce the frequency of <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b184819411816">COUNT</strong> operations, use result caching, and collect statistics by partition to minimize I/O consumption.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section16145155217486"><h4 class="sectiontitle">Suggestion 3.13: Avoid Getting Large Result Sets (Except for Data Exports)</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note129975417315"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p154121237104112"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b40846107310741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul15412637114113"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li8412113724110">If you do not need to view all the results, querying ultra-large result sets becomes inefficient and wasteful in terms of resources.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p5412937114111"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1710941969112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul9412203774112"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1285810227420">Use the <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b18362195551411">LIMIT</strong> clause to retrieve only the necessary result segments.</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li11412137104118">Use a cursor to obtain the result sets by segment and set an appropriate value for <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b719611614911">FETCH SIZE</strong> if you need to query a large number of result sets.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section18347121492"><h4 class="sectiontitle">Suggestion 3.14: Avoiding the Usage of SELECT * for Queries</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note17389173953011"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p279892064917"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1231209910741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul8798920164920"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li679811208498">Querying unnecessary columns increases the computing load and wastes computing resources.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p37986201491"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1225565402112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul8981122645019"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li198212267501">Clearly list the fields required for the query in the <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b186763110554">SELECT</strong> statement to improve the query performance.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section186162944912"><h4 class="sectiontitle">Suggestion 3.15: Using WITH RECURSIVE with Defined Termination Condition for Recursion</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note207151416205417"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p19637113195517"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b43280538710741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul96371431155520"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li8637163115515">In cases where there is no specific termination condition, recursive operations can enter an infinite loop.</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1510455155613">Recursive operations generate duplicate data and occupy excessive resources.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p1637531205510"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b2085945327112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul26371031195511"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li106377315553">Design proper termination conditions based on the volume and characteristics of the data in the service table.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section19367195264917"><h4 class="sectiontitle">Suggestion 3.16: Setting Schema Prefix for Table and Function Access</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note9255113112273"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p0744124065919"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b72631616610741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul57441840125915"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li4744114013594">If the schema name prefix is not specified, the search will be performed sequentially across all tablespaces based on the tablespace list in the current <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b62999591910">search_path</strong>. This can lead to accessing unexpected tables due to schema switchover.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p874484019594"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b2041174373112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul14744144075914"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1074419409596">To enhance readability, stability, and portability, explicitly specify the schema prefix as <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b142461822102010">SCHEMA.</strong> when accessing tables and function objects.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section72646917506"><h4 class="sectiontitle">Suggestion 3.17: Identifying an SQL Statement with a Unique SQL Comment</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note4728145992412"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p152411827813"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b212988224710741">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul1124115278115"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li4241112713118">The service's source tracing capability is limited. You can only verify it with R&amp;D engineers using the database, user name, and client IP address.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p02411227618"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b594425409112630">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul171836131044"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li4183013649">You are advised to use <strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1791151155917">query_band</strong>. The following is an example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_screen06741141944"><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">SET</span><span class="w"> </span><span class="n">query_band</span><span class="o">=</span><span class="s1">'JobName=abc;AppName=test;UserName=user'</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li1518317131848">Add a unique comment for each SQL statement to facilitate troubleshooting and application performance analysis. The following is an example of such comment.<pre class="screen" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_screen13212134918418">/* Module name_Tool name_Job name_Step */, for example, /* mca_python_xxxxxx_step1 */ insert into xxx select … from</pre>
</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_section10314162412165"><h4 class="sectiontitle">Recommendation 3.18: Restricting SQL Statements to 64 KB in Length</h4><div class="note" id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_note1037427131720"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p1837172710179"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1692396307">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul133792719173"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li937182715173">SQL parsing is time-consuming and difficult to maintain. Frequent execution of SQL statements leads to severe log expansion.</li></ul>
<p id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_p193813275174"><strong id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_b1282428773">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_ul153892712172"><li id="EN-US_TOPIC_0000002136185113__en-us_topic_0000002135806941_li173842771715">Set a 64 KB limit on SQL statements.</li></ul>
</div></div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0105.html">GaussDB(DWS) SQL Statement Development Specifications</a></div>
</div>
</div>