forked from docs/doc-exports
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: Yang, Tong <yangtong2@huawei.com> Co-committed-by: Yang, Tong <yangtong2@huawei.com>
55 lines
9.1 KiB
HTML
55 lines
9.1 KiB
HTML
<a name="mrs_01_1414"></a><a name="mrs_01_1414"></a>
|
|
|
|
<h1 class="topictitle1">Deleting Segments</h1>
|
|
<div id="body1595920210159"><div class="section" id="mrs_01_1414__s846ddce36be84308b4f10e1dfe47fec3"><h4 class="sectiontitle">Scenario</h4><p id="mrs_01_1414__acad553b1c9e1491b860b34334f33f500">If you want to modify and reload the data because you have loaded wrong data into a table, or there are too many bad records, you can delete specific segments by segment ID or data loading time.</p>
|
|
<div class="note" id="mrs_01_1414__n3e09858e88434911a97add27b52c9334"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_1414__a8ebe1fc7939d4ab083c733776b30adc9">The segment deletion operation only deletes segments that are not compacted. You can run the <b><span class="cmdname" id="mrs_01_1414__cmdname144107160444">CLEAN FILES</span></b> command to clear compacted segments.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="mrs_01_1414__s3cf158b2e7984aceae0b6d46dd0c826a"><h4 class="sectiontitle">Deleting a Segment by Segment ID</h4><p id="mrs_01_1414__afcabc5d4d8544d9d9a7651749eee3f98">Each segment has a unique ID. This segment ID can be used to delete the segment.</p>
|
|
<ol id="mrs_01_1414__o91df0e442fe3431a901f42acdc3906fe"><li id="mrs_01_1414__lde9a0b44bd07483080e1a01b795f0358"><span>Obtain the segment ID.</span><p><p id="mrs_01_1414__a4b174581a07d4d13a521d95aaa4fd139">Command:</p>
|
|
<p id="mrs_01_1414__a5bebcdc817034a3194b646be44b0b148"><b><span class="cmdname" id="mrs_01_1414__cmdname129221574517">SHOW SEGMENTS FOR Table</span></b> <i><span class="varname" id="mrs_01_1414__v1797924e775c438aac9a77689f3106d7">dbname.tablename LIMIT number_of_loads;</span></i></p>
|
|
<p id="mrs_01_1414__a95710643c9104e38843cafd46e59369c">Example:</p>
|
|
<p id="mrs_01_1414__ab3c638c0881f495db2b2b501d8725811"><b><span class="cmdname" id="mrs_01_1414__cmdname1228891934516">SHOW SEGMENTS FOR TABLE</span></b> <i><span class="varname" id="mrs_01_1414__vfa6d9f65617044a9990d584a37f62843">carbonTable;</span></i></p>
|
|
<p id="mrs_01_1414__a6104eec48f904204b03394f7c1fc0bfd">Run the preceding command to show all the segments of the table named <strong id="mrs_01_1414__b519472110711">carbonTable</strong>.</p>
|
|
<p id="mrs_01_1414__af44bcf79dc5d425fbd2986178fc50184"><b><span class="cmdname" id="mrs_01_1414__cmdname19654132314519">SHOW SEGMENTS FOR TABLE</span></b> <i><span class="varname" id="mrs_01_1414__va88f7ccbf0f144548abd75665542eb36">carbonTable LIMIT 2;</span></i></p>
|
|
<p id="mrs_01_1414__ab7cafad1acb2439e9bf524a27ffe0ca2">Run the preceding command to show segments specified by <i><span class="varname" id="mrs_01_1414__v544fffc4c00c4408b2027d165f445638">number_of_loads</span></i>.</p>
|
|
<p id="mrs_01_1414__ac4080743ba104b06b49b955a4c6c96df">The command output is as follows:</p>
|
|
<pre class="screen" id="mrs_01_1414__sf2d7cff41c01412f971acdec8808ce90">+-----+----------+--------------------------+------------------+------------+------------+-------------+--------------+--+
|
|
| ID | Status | Load Start Time | Load Time Taken | Partition | Data Size | Index Size | File Format |
|
|
+-----+----------+--------------------------+------------------+------------+------------+-------------+--------------+--+
|
|
| 3 | Success | 2020-09-28 22:53:26.336 | 3.726S | {} | 6.47KB | 3.30KB | columnar_v3 |
|
|
| 2 | Success | 2020-09-28 22:53:01.702 | 6.688S | {} | 6.47KB | 3.30KB | columnar_v3 |
|
|
+-----+----------+--------------------------+------------------+------------+------------+-------------+--------------+--+</pre>
|
|
<div class="note" id="mrs_01_1414__ncd0e37ead3f645f88f0add2d1097ead1"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="mrs_01_1414__a129cd94944834d839f84758d7d70ebe6">The output of the <b><span class="cmdname" id="mrs_01_1414__cmdname11663182915452">SHOW SEGMENTS</span></b> command includes ID, Status, Load Start Time, Load Time Taken, Partition, Data Size, Index Size, and File Format. The latest loading information is displayed in the first line of the command output.</p>
|
|
</div></div>
|
|
</p></li><li id="mrs_01_1414__lc6bd27d81b524721a4e2b66dd85b7575"><span>Run the following command to delete the segment after you have found the Segment ID:</span><p><p id="mrs_01_1414__a99d478582c8f423a921b5157612ec31c">Command:</p>
|
|
<p id="mrs_01_1414__abba521e3afd64b7f93cf163b164a295b"><b><span class="cmdname" id="mrs_01_1414__cmdname1425533444517">DELETE FROM TABLE tableName WHERE SEGMENT.ID IN (load_sequence_id1, load_sequence_id2, ....)</span></b>;</p>
|
|
<p id="mrs_01_1414__a63fe95c33a27436993cbdcffc5994193">Example:</p>
|
|
<p id="mrs_01_1414__a1d90f8f7393a43d18f636991786034be"><b><span class="cmdname" id="mrs_01_1414__cmdname14313103814456">DELETE FROM TABLE carbonTable WHERE SEGMENT.ID IN (1,2,3)</span></b>;</p>
|
|
<p id="mrs_01_1414__ad8917c34649349fa95df212a8ecfa035">For details, see <a href="mrs_01_1442.html">DELETE SEGMENT by ID</a>.</p>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="mrs_01_1414__s394d1905e13b41d29d87e05bac74a8d8"><h4 class="sectiontitle">Deleting a Segment by Data Loading Time</h4><p id="mrs_01_1414__a8de1f36c2da144288948166d4df339a9">You can delete a segment based on the loading time.</p>
|
|
<p id="mrs_01_1414__a2171b1060b79490b9d47afecde885d37">Command:</p>
|
|
<p id="mrs_01_1414__a09a81087159245f59322a5cdcaf7741a"><b><span class="cmdname" id="mrs_01_1414__cmdname05701743164516">DELETE FROM TABLE db_name.table_name WHERE SEGMENT.STARTTIME BEFORE date_value</span></b>;</p>
|
|
<p id="mrs_01_1414__a9909a9a8cacf4556b37019738ca7ebb3">Example:</p>
|
|
<p id="mrs_01_1414__af1039202950f4d0ea115b284981937c8"><b><span class="cmdname" id="mrs_01_1414__cmdname13604546104516">DELETE FROM TABLE carbonTable WHERE SEGMENT.STARTTIME BEFORE '2017-07-01 12:07:20'</span></b>;</p>
|
|
<p id="mrs_01_1414__a671f3f00be8d4db2986a89ffda342991">The preceding command can be used to delete all segments before 2017-07-01 12:07:20.</p>
|
|
<p id="mrs_01_1414__a65b1629fe30648289fd2e46da76cd345">For details, see <a href="mrs_01_1443.html">DELETE SEGMENT by DATE</a>.</p>
|
|
</div>
|
|
<div class="section" id="mrs_01_1414__s4b3eb833316b4104abeca64f7d12aa12"><h4 class="sectiontitle">Result</h4><p id="mrs_01_1414__acf233b8c6419458d996cbe0436d16c45">Data of corresponding segments is deleted and is unavailable for query. You can run the <b><span class="cmdname" id="mrs_01_1414__cmdname17514165216454">SHOW SEGMENTS</span></b> command to display the segment status and check whether the segment has been deleted.</p>
|
|
<div class="note" id="mrs_01_1414__n18da446833514705b40d4e252490b8c5"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><ul id="mrs_01_1414__u35644c177c5a4edebd271959109706f2"><li id="mrs_01_1414__lc517ec68469147b482b24544b60496cb">Segments are not physically deleted after the execution of the <b><span class="cmdname" id="mrs_01_1414__cmdname1480115612455">DELETE SEGMENT</span></b> command. Therefore, if you run the <b><span class="cmdname" id="mrs_01_1414__cmdname11208191184616">SHOW SEGMENTS</span></b> command to check the status of a deleted segment, it will be marked as <strong id="mrs_01_1414__b12953192581118">Marked for Delete</strong>. If you run the <b><span class="cmdname" id="mrs_01_1414__cmdname544710416469">SELECT * FROM tablename</span></b> command, the deleted segment will be excluded.</li><li id="mrs_01_1414__l8087385ef5d5482abd34fc5a353b2693">The deleted segment will be deleted physically only when the next data loading reaches the maximum query execution duration, which is configured by the <span class="parmname" id="mrs_01_1414__p8d6e6eab9fa940abb0fab6b4bb05b38e"><b>max.query.execution.time</b></span> parameter. The default value of the parameter is 60 minutes.</li><li id="mrs_01_1414__l38d2407f0abd4e10824559ae1763b4ed">If you want to forcibly delete a physical segment file, run the <b><span class="cmdname" id="mrs_01_1414__cmdname78862864610">CLEAN FILES</span></b> command.<p id="mrs_01_1414__a52829ad61a5e4f5293e235447d1f84bd">Example:</p>
|
|
<p id="mrs_01_1414__a92fcac96108c48ef9048b9e0d6278726"><b><span class="cmdname" id="mrs_01_1414__cmdname875951310469">CLEAN FILES FOR TABLE table1;</span></b></p>
|
|
<p id="mrs_01_1414__a1c3c33700d52434a96905ceb4438e322">This command will physically delete the segment file in the <strong id="mrs_01_1414__b118519141122">Marked for delete</strong> state.</p>
|
|
<p id="mrs_01_1414__aff2754358bb74221a35efbfbbe9b3fa1">If this command is executed before the time specified by <span class="parmname" id="mrs_01_1414__p2a5aaf7b14cf40fc87447284a5d5e7eb"><b>max.query.execution.time</b></span> arrives, the query may fail. <span class="parmname" id="mrs_01_1414__pdefd9cf202a14ee089eb58a6e41ee451"><b>max.query.execution.time</b></span> indicates the maximum time allowed for a query, which is set in the <span class="filepath" id="mrs_01_1414__fabb9dcb95da6496e8cdb4906ffd24d04"><b>carbon.properties</b></span> file.</p>
|
|
</li></ul>
|
|
</div></div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="mrs_01_1412.html">CarbonData Table Data Management</a></div>
|
|
</div>
|
|
</div>
|
|
|