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 TABLE table_name [nowait];
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.
openGauss=# CREATE TABLE row_compression
(
    id int
) with (compresstype=2, compress_chunk_size = 512, compress_level = 1);

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

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

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

--Delete the table.
openGauss=# DROP TABLE row_compression;
Feedback
编组 3备份
    openGauss 2024-12-26 01:06:46
    cancel