tencent cloud

Feedback

Second-Level Column Modification

Last updated: 2024-06-18 14:39:37

    Description of the Feature

    Second-level Column Modification operations are only recorded in the Data Dictionary Table to log Column Modification Information, avoiding the data copying that was previously necessary for column modification operations. This significantly reduces the time required for Large Table Column Modifications, minimizing the impact on Application Systems and resource consumption.

    Supported Versions

    Kernel version MySQL 8.0 20230630 and above.

    Applicable Scenario

    This feature is suitable for modifying columns in Tables with Large Data Volumes.

    Test Results

    Number of table rows
    Modification Duration without using Second-level Column Modification Feature
    Modification Duration with Second-level Column Modification Feature
    1 million
    22.9 seconds
    0.01 seconds
    10 Million
    13 minutes and 39.72 seconds
    0.01 seconds
    100 million
    3 hours, 51 minutes, 16.40 seconds
    0.01 seconds

    Use Instructions

    Second-level Column Modification Syntax ALTER TABLE add algorithm = instant Clause, column modification can be performed with the following statement:
    ALTER TABLE modify_tab_col MODIFY COLUMN c1 BIGINT,ALGORITHM=INSTANT;
    Add the parameter cdb_instant_modify_column_enabled to control the Second-level Column Modification feature, which can be set to ON/OFF.
    Parameter Name
    
    Status
    
    Type
    
    Default Value
    
    Valid Values/Value Range
    Description
    
    cdb_instant_modify_column_enabled
    
    yes
    
    bool
    
    OFF
    
    ON/OFF
    
    Feature Toggle, determining whether to enable the Second-level Column Modification feature.
    Note:
    Users cannot directly modify the parameter values mentioned above. To make changes, submit a ticket.

    Second-level Column Modification Restrictions

    Support is limited to modifying column types only; changes to the field's nullable, unsigned/signed, charset are not supported, but modifying the default property is allowed.
    Only certain type modifications are supported, and only length can be increased. Currently, conversions are only supported between char and varchar, binary and varbinary, and amongst tinyint/smallint/mediumint/int/bigint.
    For example:
    char(10) → char(100)
    char(10) → varchar(100)
    varchar(10) → char(100)
    varchar(10) → varchar(100)
    binary(10) → binary(100)
    binary(10) → varbinary(100)
    varbinary(10) → binary(100)
    varbinary(10) → varbinary(100)
    tinyint/smallint/mediumint/int → bigint
    tinyint/smallint/mediumint → int
    tinyint/smallint → mediumint
    tinyint → smallint
    Note:
    Modifications between char/varchar and binary/varbinary, as well as integer types, are not supported. For example, changing from char to binary, binary to varchar, or reducing the range of integer types, such as from bigint to int or int to smallint, is not allowed.
    A single column can only be modified using INSTANT MODIFY COLUMN once, but multiple columns can be modified with it simultaneously.
    After a single column is added/modified using INSTANT ADD/MODIFY COLUMN for the first time, any subsequent modifications to that column must be done in a non-instant manner.
    INSTANT ADD COLUMNS and INSTANT MODIFY COLUMNS operations must be executed separately. You may first execute INSTANT ADD COLUMNS, then INSTANT MODIFY COLUMNS, or vice versa. You cannot perform INSTANT MODIFY COLUMN on a column that has been added with INSTANT ADD COLUMN.
    You cannot modify the column name and column type at the same time. Instead, you can modify the column name first and then column type.
    Import/export is not supported.
    Encryption and compression are not supported.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support