doc-exports/docs/dws/dev/dws_04_0084.html
Lu, Huayi ef0ada5a59 DWS DEV 20240716 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-11-02 09:07:47 +00:00

67 lines
26 KiB
HTML

<a name="EN-US_TOPIC_0000001510283305"></a><a name="EN-US_TOPIC_0000001510283305"></a>
<h1 class="topictitle1">GaussDB(DWS) SQL Writing Rules</h1>
<div id="body1528161858339"><div class="section" id="EN-US_TOPIC_0000001510283305__section60205875143313"><h4 class="sectiontitle">DDL</h4><ul id="EN-US_TOPIC_0000001510283305__ul1972862419595"><li id="EN-US_TOPIC_0000001510283305__li1072832415918">[Proposal] In <span id="EN-US_TOPIC_0000001510283305__text526581581">GaussDB(DWS)</span>, you are advised to execute DDL operations, such as creating table or making comments, separately from batch processing jobs to avoid performance deterioration caused by many concurrent transactions.</li><li id="EN-US_TOPIC_0000001510283305__li5212735919">[Proposal] Execute data truncation after unlogged tables are used because <span id="EN-US_TOPIC_0000001510283305__text281995683">GaussDB(DWS)</span> cannot ensure the security of unlogged tables in abnormal scenarios.</li><li id="EN-US_TOPIC_0000001510283305__li1719012919599">[Proposal] Suggestions on the storage mode of temporary and unlogged tables are the same as those on base tables. Create temporary tables in the same storage mode as the base tables to avoid high computing costs caused by hybrid row and column correlation.</li><li id="EN-US_TOPIC_0000001510283305__li1661583105916">[Proposal] The total length of an index column cannot exceed 50 bytes. Otherwise, the index size will increase greatly, resulting in large storage cost and low index performance.</li><li id="EN-US_TOPIC_0000001510283305__li17294434115910">[Proposal] Do not delete objects using <strong id="EN-US_TOPIC_0000001510283305__b175334270593533">DROP...CASCADE</strong>, unless the dependency between objects is specified. Otherwise, the objects may be deleted by mistake.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283305__section45234071153513"><h4 class="sectiontitle">Data Loading and Uninstalling</h4><ul id="EN-US_TOPIC_0000001510283305__ul866153885912"><li id="EN-US_TOPIC_0000001510283305__li1466143811599">[Proposal] Provide the inserted column list in the insert statement. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen206623818595"><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">INSERT</span><span class="w"> </span><span class="k">INTO</span><span class="w"> </span><span class="n">task</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="n">id</span><span class="p">,</span><span class="k">comment</span><span class="p">)</span><span class="w"> </span><span class="k">VALUES</span><span class="w"> </span><span class="p">(</span><span class="s1">'task1'</span><span class="p">,</span><span class="s1">'100'</span><span class="p">,</span><span class="s1">'100th task'</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283305__li1018434110596">[Proposal] After data is imported to the database in batches or the data increment reaches the threshold, you are advised to analyze tables to prevent the execution plan from being degraded due to inaccurate statistics.</li><li id="EN-US_TOPIC_0000001510283305__li18713443105913">[Proposal] To clear all data in a table, you are advised to use <strong id="EN-US_TOPIC_0000001510283305__b1688884693638">TRUNCATE TABLE</strong> instead of <strong id="EN-US_TOPIC_0000001510283305__b200528289993638">DELETE TABLE</strong>. <strong id="EN-US_TOPIC_0000001510283305__b60032975893717">DELETE TABLE</strong> is not efficient and cannot release disk space occupied by the deleted data.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283305__section28537273145311"><h4 class="sectiontitle">Type conversion</h4><ul id="EN-US_TOPIC_0000001510283305__ul11745246115918"><li id="EN-US_TOPIC_0000001510283305__li27451746135914">[Proposal] Perform type coercion to convert data types. If you perform implicit conversion, the result may differ from expected.</li><li id="EN-US_TOPIC_0000001510283305__li3440349125917">[Proposal] During data query, explicitly specify the data type for constants, and do not attempt to perform any implicit data type conversion.</li><li id="EN-US_TOPIC_0000001510283305__li1731052145918">[Notice] In Oracle compatibility mode, null strings will be automatically converted to NULL during data import. If a null string needs to be reserved, you need to create a database that is compatible with Teradata.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0000001510283305__section48841047154511"><h4 class="sectiontitle">Query Operation</h4><ul id="EN-US_TOPIC_0000001510283305__ul31156185916"><li id="EN-US_TOPIC_0000001510283305__li1311156185914">[Proposal] Do not return a large number of result sets to a client except the ETL program. If a large result set is returned, consider modifying your service design.</li><li id="EN-US_TOPIC_0000001510283305__li8373115875917">[Proposal] Perform DDL and DML operations encapsulated in transactions. Operations like table truncation, update, deletion, and dropping, cannot be rolled back once committed. You are advised to encapsulate such operations in transactions so that you can roll back the operations if necessary.</li><li id="EN-US_TOPIC_0000001510283305__li13858707018">[Proposal] During query compilation, you are advised to list all columns to be queried and avoid using <strong id="EN-US_TOPIC_0000001510283305__b842352706162352">*</strong>. Doing so reduces output lines, improves query performance, and avoids the impact of adding or deleting columns on front-end service compatibility.</li><li id="EN-US_TOPIC_0000001510283305__li18254841303">[Proposal] During table object access, add the schema prefix to the table object to avoid accessing an unexpected table due to schema switchover.</li><li id="EN-US_TOPIC_0000001510283305__li36071160012">[Proposal] The cost of joining more than three tables or views, especially full joins, is difficult to be estimated. You are advised to use the <strong id="EN-US_TOPIC_0000001510283305__b842352706114736">WITH TABLE AS</strong> statement to create interim tables to improve the readability of SQL statements.</li><li id="EN-US_TOPIC_0000001510283305__li17291295012">[Proposal] Do not use Cartesian products or full joins. Cartesian products and full joins will result in a sharp expansion of result sets and poor performance.</li><li id="EN-US_TOPIC_0000001510283305__li142772131306">[Notice] Only <strong id="EN-US_TOPIC_0000001510283305__b842352706115240">IS NULL</strong> and <strong id="EN-US_TOPIC_0000001510283305__b842352706115243">IS NOT NULL</strong> can be used to determine NULL value comparison results. If any other method is used, NULL is returned. For example, <strong id="EN-US_TOPIC_0000001510283305__b1727151044012">NULL</strong> instead of expected Boolean values is returned for <strong id="EN-US_TOPIC_0000001510283305__b842352706115627">NULL&lt;&gt;NULL</strong>, <strong id="EN-US_TOPIC_0000001510283305__b842352706115631">NULL=NULL</strong>, and <strong id="EN-US_TOPIC_0000001510283305__b842352706115635">NULL&lt;&gt;1</strong>.</li><li id="EN-US_TOPIC_0000001510283305__li16640101611013">[Notice] Do not use count(col) instead of count(*) to count the total number of records in a table. count(*) counts the NULL value (actual rows) while count (col) does not.</li><li id="EN-US_TOPIC_0000001510283305__li94211913016">[Notice] While executing count(col), the number of NULL record rows is counted as 0. While executing sum(col), NULL is returned if all records are NULL. If not all the records are NULL, the number of NULL record rows is counted as 0.</li><li id="EN-US_TOPIC_0000001510283305__li96616211405">[Notice] To count multiple columns using count(), column names must be enclosed with parentheses. For example, count ((col1, col2, col3)). Note: When multiple columns are used to count the number of NULL record rows, a row is counted even if all the selected columns are NULL. The result is the same as that when count(*) is executed.</li><li id="EN-US_TOPIC_0000001510283305__li159382516013">[Notice] Null records are not counted when count(distinct col) is used to calculate the number of non-null columns that are not repeated.</li><li id="EN-US_TOPIC_0000001510283305__li174733286016">[Notice] If all statistical columns are NULL when count(distinct (col1,col2,...)) is used to count the number of unique values in multiple columns, Null records are also counted, and the records are considered the same.</li><li id="EN-US_TOPIC_0000001510283305__li875853413494">[Notice] When constants are used to filter data, the system searches for functions used for calculating these two data types based on the data types of the constants and matched columns. If no function is found, the system converts the data type implicitly. Then, the system searches for a function used for calculating the converted data type.<pre class="screen" id="EN-US_TOPIC_0000001510283305__screen1269491605712">SELECT * FROM test WHERE timestamp_col = 20000101;</pre>
<p id="EN-US_TOPIC_0000001510283305__p3801145495418">In the preceding example, if <strong id="EN-US_TOPIC_0000001510283305__b4478175201020">timestamp_col</strong> is the timestamp type, the system first searches for the function that supports the "equal" operation of the timestamp and int types (constant numbers are considered as the int type). If no such function is found, the <strong id="EN-US_TOPIC_0000001510283305__b1528517173164">timestamp_col</strong> data and constant numbers are implicitly converted into the text type for calculation.</p>
</li><li id="EN-US_TOPIC_0000001510283305__li54741939206">[Proposal] Do not use scalar subquery statements. A scalar subquery appears in the output list of a <strong id="EN-US_TOPIC_0000001510283305__b84235270615556">SELECT</strong> statement. In the following example, the part enclosed in parentheses is a scalar subquery statement:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen047418392014"><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="n">id</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="k">COUNT</span><span class="p">(</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">films</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">f</span><span class="p">.</span><span class="n">did</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">s</span><span class="p">.</span><span class="n">id</span><span class="p">)</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">staffs_p1</span><span class="w"> </span><span class="n">s</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p65339406113426">Scalar subqueries often result in query performance deterioration. During application development, scalar subqueries need to be converted into equivalent table associations based on the service logic.</p>
</li><li id="EN-US_TOPIC_0000001510283305__li6104647302">[Proposal] In <strong id="EN-US_TOPIC_0000001510283305__b842352706172811">WHERE</strong> clauses, the filtering conditions should be sorted. The condition that few records are selected for reading (the number of filtered records is small) is listed at the beginning.</li><li id="EN-US_TOPIC_0000001510283305__li20777449808">[Proposal] Filtering conditions in <strong id="EN-US_TOPIC_0000001510283305__b842352706172821">WHERE</strong> clauses should comply with unilateral rules. That is, when the column name is placed on one side of a comparison operator, the optimizer automatically performs pruning optimization in some scenarios. Filtering conditions in a <strong id="EN-US_TOPIC_0000001510283305__b124629312895126">WHERE</strong> clause will be displayed in <strong id="EN-US_TOPIC_0000001510283305__b139129845295126">col op expression</strong> format, where <strong id="EN-US_TOPIC_0000001510283305__b119823048695126">col</strong> indicates a table column, <strong id="EN-US_TOPIC_0000001510283305__b1037389995126">op</strong> indicates a comparison operator, such as = and &gt;, and <strong id="EN-US_TOPIC_0000001510283305__b89754445695126">expression</strong> indicates an expression that does not contain a column name. For example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen677711491903"><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="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="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">current_timestamp</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="k">time</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="s1">'1 days'</span><span class="p">::</span><span class="nb">interval</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p26912854112759">The modification is as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen40889095112759"><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="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="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">face_data</span><span class="w"> </span><span class="k">where</span><span class="w"> </span><span class="k">time</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="k">current_timestamp</span><span class="p">(</span><span class="mi">6</span><span class="p">)</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="s1">'1 days'</span><span class="p">::</span><span class="nb">interval</span><span class="p">;</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283305__li18346183117">[Proposal] Do not perform unnecessary sorting operations. Sorting requires a large amount of memory and CPU. If service logic permits, <strong id="EN-US_TOPIC_0000001510283305__b842352706164621">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001510283305__b842352706164624">LIMIT</strong> can be combined to reduce resource overhead. By default, data in <span id="EN-US_TOPIC_0000001510283305__text30313868">GaussDB(DWS)</span> is sorted by ASC &amp; NULL LAST.</li><li id="EN-US_TOPIC_0000001510283305__li1294114512111">[Proposal] When the <strong id="EN-US_TOPIC_0000001510283305__b842352706164757">ORDER BY</strong> clause is used for sorting, specify sorting modes (ASC or DESC), and use NULL FIRST or NULL LAST for NULL record sorting.</li><li id="EN-US_TOPIC_0000001510283305__li5371188317">[proposal] Do not rely on only the <strong id="EN-US_TOPIC_0000001510283305__b842352706165145">LIMIT</strong> clause to return the result set displayed in a specific sequence. Combine <strong id="EN-US_TOPIC_0000001510283305__b842352706165346">ORDER BY</strong> and <strong id="EN-US_TOPIC_0000001510283305__b842352706165350">LIMIT</strong> clauses for some specific result sets and use offset to skip specific results if necessary.</li><li id="EN-US_TOPIC_0000001510283305__li861011115">[Proposal] If the service logic is accurate, you are advised to use <strong id="EN-US_TOPIC_0000001510283305__b84235270617118">UNION ALL</strong> instead of <strong id="EN-US_TOPIC_0000001510283305__b84235270617121">UNION</strong>.</li><li id="EN-US_TOPIC_0000001510283305__li957714131716">[Proposal] If a filtering condition contains only an <strong id="EN-US_TOPIC_0000001510283305__b84235270617126">OR</strong> expression, convert the <strong id="EN-US_TOPIC_0000001510283305__b84235270617135">OR </strong>expression to <strong id="EN-US_TOPIC_0000001510283305__b84235270617131">UNION ALL</strong> to improve performance. SQL statements that use <strong id="EN-US_TOPIC_0000001510283305__b84235270617155">OR</strong> expressions cannot be optimized, resulting in slow execution. Example:<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen1757791320111"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
<span class="normal">2</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">scdc</span><span class="p">.</span><span class="n">pub_menu</span><span class="w"> </span>
<span class="k">WHERE</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">300</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">)</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">301</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">302</span><span class="p">)</span><span class="w"> </span><span class="k">OR</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">302</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p9824563112759">Convert the statement to the following:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen36954014112759"><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></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">scdc</span><span class="p">.</span><span class="n">pub_menu</span><span class="w"> </span>
<span class="k">WHERE</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">300</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">)</span><span class="w"> </span>
<span class="k">union</span><span class="w"> </span><span class="k">all</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">scdc</span><span class="p">.</span><span class="n">pub_menu</span><span class="w"> </span>
<span class="k">WHERE</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">301</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">302</span><span class="p">)</span><span class="w"> </span>
<span class="k">union</span><span class="w"> </span><span class="k">all</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">scdc</span><span class="p">.</span><span class="n">pub_menu</span><span class="w"> </span>
<span class="k">WHERE</span><span class="w"> </span><span class="p">(</span><span class="n">cdp</span><span class="o">=</span><span class="w"> </span><span class="mi">302</span><span class="w"> </span><span class="k">AND</span><span class="w"> </span><span class="n">inline</span><span class="o">=</span><span class="mi">301</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
</li><li id="EN-US_TOPIC_0000001510283305__li88758236119">[Proposal] If an <strong id="EN-US_TOPIC_0000001510283305__b14611738104614">in(val1, val2, va...)</strong> expression contains a large number of columns, you are advised to replace it with the <strong id="EN-US_TOPIC_0000001510283305__b1061153813465">in (values (va1), (val2),(val3...)</strong> statement. The optimizer will automatically convert the <strong id="EN-US_TOPIC_0000001510283305__b1458111681316">IN</strong> constraint into a non-correlated subquery to improve the query performance.</li><li id="EN-US_TOPIC_0000001510283305__li1837032616114">[Proposal] Replace <strong id="EN-US_TOPIC_0000001510283305__b842352706174314">(not) in</strong> with <strong id="EN-US_TOPIC_0000001510283305__b842352706174319">(not) exist</strong> when associated columns do not contain <strong id="EN-US_TOPIC_0000001510283305__b176681586284">NULL</strong> values. For example, in the following query statement, if the T1.C1 column does not contain any NULL value, add the NOT NULL constraint to the T1.C1 column, and then rewrite the statements.<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen133702262115"><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">T1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">T1</span><span class="p">.</span><span class="n">C1</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">IN</span><span class="w"> </span><span class="p">(</span><span class="k">SELECT</span><span class="w"> </span><span class="n">T2</span><span class="p">.</span><span class="n">C2</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">T2</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<p id="EN-US_TOPIC_0000001510283305__p58071969112759">Rewrite the statement as follows:</p>
<div class="codecoloring" codetype="Sql" id="EN-US_TOPIC_0000001510283305__screen52885675112759"><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">T1</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="k">NOT</span><span class="w"> </span><span class="k">EXISTS</span><span class="w"> </span><span class="p">(</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">T1</span><span class="p">,</span><span class="n">T2</span><span class="w"> </span><span class="k">WHERE</span><span class="w"> </span><span class="n">T1</span><span class="p">.</span><span class="n">C1</span><span class="o">=</span><span class="n">T2</span><span class="p">.</span><span class="n">C2</span><span class="p">);</span>
</pre></div></td></tr></table></div>
</div>
<div class="note" id="EN-US_TOPIC_0000001510283305__note30088550112759"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="EN-US_TOPIC_0000001510283305__ul33169334112759"><li id="EN-US_TOPIC_0000001510283305__li6209029112759">If the value of the T1.C1 column will possibly be NULL, the preceding rewriting cannot be performed.</li><li id="EN-US_TOPIC_0000001510283305__li55881264112759">If T1.C1 is the output of a subquery, check whether the output is NOT NULL based on the service logic.</li></ul>
</div></div>
</li><li id="EN-US_TOPIC_0000001510283305__li145891038416">[Proposal] Use cursors instead of the <strong id="EN-US_TOPIC_0000001510283305__b842352706171649">LIMIT OFFSET</strong> syntax to perform pagination queries to avoid resource overheads caused by multiple executions. A cursor must be used in a transaction, and you must disable it and commit transaction once the query is finished.</li></ul>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0074.html">GaussDB(DWS) Development and Design Proposal</a></div>
</div>
</div>