Files
doc-exports/docs/dws/dev/dws_04_0116.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

23 lines
4.0 KiB
HTML

<a name="EN-US_TOPIC_0000002136265445"></a><a name="EN-US_TOPIC_0000002136265445"></a>
<h1 class="topictitle1">INSERT Operation </h1>
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_section1588193713503"><h4 class="sectiontitle">Rule 3.3: Replacing INSERT with COPY for Efficient Multi-Value Batch Insertion</h4><div class="note" id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_note4102113972211"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_p3291449204611"><strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b27868245010740">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_ul13291154984618"><li id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_li5931185322219">Parsing multiple values is time-consuming and resource-intensive, leading to low efficiency when importing data into the database.</li></ul>
<p id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_p1929111496465"><strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b2137453572112628">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_ul45271052172"><li id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_li352714521971">Instead of using <strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b7128536153017">INSERT VALUES</strong>, the frontend should use APIs like CopyManager of JDBC.</li></ul>
</div></div>
</div>
<div class="section" id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_section2595105519505"><h4 class="sectiontitle">Suggestion 3.4: Avoiding Performing Real-time INSERT Operations on Common Column-store Tables</h4><div class="note" id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_note8240726121019"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_p12240152631010"><strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b40092319010740">Impact of rule violation:</strong></p>
<ul id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_ul1855818287113"><li id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_li4558182871110">Importing a small batch of data in real-time to a common column-store table can significantly expand the small CU, occupying a lot of storage space and impacting the query performance.</li></ul>
<p id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_p16240142613109"><strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b1428245868112628">Solution:</strong></p>
<ul id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_ul224092615105"><li id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_li4241192681010">In real-time <strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b2054971673313">INSERT</strong> scenarios, evaluate the amount of data to be imported at once and the total amount of data. If the total amount of data is small, use row-store tables.</li><li id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_li1692863620118">In the real-time INSERT scenario, import around 60,000 data records to a single table, partition, or DN at a time. The minimum import batch is 5,000 data records.</li><li id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_li10663131918438">In the real-time <strong id="EN-US_TOPIC_0000002136265445__en-us_topic_0000002135726605_b312692211346">INSERT</strong> scenario, use H-Store column-store tables (for clusters of version 8.3.0 or later).</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>