HomeMogDBMogDB StackUqbar
v3.1

Documentation:v3.1

Supported Versions:

Other Versions:

SHRINK

Function

Shrinks chunks in a specified compressed table to facilitate page read and write.

Precautions

  • The shrink operation is performed only on the primary node and cannot be manually performed on the standby node.
  • The shrink operation time is related to the current CPU usage and table size.
  • Shrink is an optimization operation. If the database is abnormal during optimization, the optimization will not continue after the database is restarted.

Syntax

Shrink ::= SHRINK TABLE table_name [nowait];
Shrink ::= SHRINK INDEX index_name [nowait];

Parameter Description

  • nowait

    Indicates that a task is returned immediately after being initiated without waiting for the sorting result. The daemon thread periodically wakes up to sort the tasks added by shrink.

Example

The following uses SHRINK TABLE as an example. The operation of SHRINK INDEX is the same as that of SHRINK TABLE.

--Create the row_compression table.
MogDB=# CREATE TABLE row_compression
(
    id int
) with (compresstype=2, compress_chunk_size = 512, compress_level = 1);

--Insert data.
MogDB=# Insert into row_compression select generate_series(1,1000);

--View data.
MogDB=# SELECT * FROM row_compression;

--Shrink the table.
MogDB=# SHRINK TABLE row_compression;

--Delete the table.
MogDB=# DROP TABLE row_compression;
Copyright © 2011-2024 www.enmotech.com All rights reserved.