All Products
Search
Document Center

Data Management:Lockless data change

Last Updated:Mar 30, 2026

When you run UPDATE or DELETE on a large table, a standard transaction locks the table until the operation finishes — blocking reads and writes and risking timeouts that disrupt production traffic. Lock-free data change avoids this by splitting the affected rows into small batches and processing each batch as a separate, short-lived transaction. Each batch commits and releases its lock immediately, so the table stays responsive throughout.

How it works

DMS divides the affected rows into chunks based on the table's primary key or unique key. For each chunk, DMS applies the change, commits, and moves to the next chunk. No single transaction holds a lock long enough to block concurrent reads or writes.

Requirements

The table must have:

  • A primary key, or

  • A unique key that does not accept null values

Limitations

  • Operates on a single table only

  • Supports simple SQL statements: SELECT, UPDATE, and DELETE

  • Does not support multi-table statements, such as DELETE with JOIN

Submit a lock-free change

This example updates all rows in big_table<\/code> where id < 1,000,000<\/code>, setting long_text_b<\/code> to 'random long text'<\/code>.<\/code>

The process involves two roles:

  1. A regular user submits the change ticket

  2. A DMS administrator approves and executes it

Submit the ticket (regular user)

  1. Log in to the DMS console V5.0 as a regular user.

  2. In the top navigation bar, choose Database Development > Data Change > Lockless change.

    In simple mode, hover over the 2023-01-28_15-57-17.png icon in the upper-left corner and choose All Features > Database Development > Data Change > Lockless Change.
  3. Configure the following parameters and click Submit. For this example, enter the following statement in SQL Statements for Change:

    Parameter Required Description
    Database Yes Select poc_dev<\/code>.<\/code>
    Business Background No Describe your business requirements to reduce back-and-forth with approvers.
    Affected Rows Yes Estimate the number of rows this change will affect. Run a COUNT<\/code> query in the SQL Console to get this number.<\/code>
    SQL Statements for Change Yes Enter the UPDATE or DELETE statement to execute.
    UPDATE `big_table` SET `long_text_b` = 'random long text' WHERE id < 1000000;<\/code><\/code>
  4. On the ticket details page, click chunk option. In the dialog that appears, configure the batch execution settings and click Submit Change.

    分批执行配置

  5. Review the ticket details. Before execution, DMS runs a precheck on your SQL statement that covers:

    Precheck item What it validates
    Syntax validation Catches SQL errors before the change runs
    Statement type Confirms the statement type matches your security rule configuration
    Permissions Verifies the submitting user has the required permissions
    Row scan estimate Estimates the number of rows to be scanned
  6. After the precheck passes, click Submit for Approval, then click OK in the confirmation dialog.

    Important

    You can only edit the ticket before submitting it for approval.

Approve and execute the ticket (DMS administrator)

  1. Log in to the DMS console V5.0 as a DMS administrator.

  2. On the DMS console homepage, click Pending Tickets in the My Tickets section.

  3. On the My Tickets page, click the ticket number in the Ticket Number column to open the ticket.

  4. In the Ticket Details panel, review the change details and click Approve.

  5. In the approval dialog, enter your comments and click Submit.

  6. In the Execute step, click Execute Change. Set Execution Strategy to Running immediately and click Confirm Execution.

    - Execution Strategy defaults to Running immediately. Select Schedule to set a specific execution time. - Enable Specify End Time to automatically stop execution at a set time, preventing the change from running during peak hours.
  7. To monitor progress, click Details in the Execute step, then select Execution Progress.

Verify the change

After the change completes, run a SELECT query to confirm the data was updated correctly.

  1. Log in to the DMS console V5.0 as a DMS administrator.

  2. In the instance list, expand the POC_dev<\/code> instance and double-click the poc_dev<\/code> database to open the SQL Console.<\/code>

  3. Run the following query and confirm that the long_text_b<\/code> field shows the updated values:<\/code>

    SELECT * FROM `big_table`;<\/code>

    无锁数据变更验证

    <\/code>