Skip to main content

Update Data

Choose an update method based on your table model, write frequency, and whether each record contains a full row or only changed columns. For row-level updates, use a Unique Key table.

1. Choose the right update method​

1.1 Compare table models and update capabilities​

VeloDB Cloud provides three table models, with significant differences in support for updates and deletions. When making a selection, first confirm whether your business requires row-level updates or partial column updates.

Table ModelData OrganizationSupported Update/Delete MethodsTypical Use Cases
Unique Key ModelEach row is identified by a unique primary key, deduplicated on writeUPSERT, partial column update, UPDATE, marked deletion, DELETEOrder status changes, user tag updates, CDC synchronization
Aggregate Key ModelValue columns with the same Key are merged by aggregation function (SUM/MAX/MIN/REPLACE)Updated through ingestion based on aggregation semantics; DELETE only supports Key column conditionsReal-time reports, click counts, and other aggregation scenarios
Duplicate Key ModelAppend-only writes, no deduplication or aggregationOnly supports DELETELogs, behavior tracking, and other append-only scenarios

Choose a Unique Key table: Choose the Unique Key model when row-level updates or partial column updates are required.

1.2 Choose an update path​

The Unique Key model supports two update paths, which can be chosen based on data scale and business frequency:

PathApplicable ScenariosRecommended Write Method
Ingest-based update (UPSERT)High-frequency, large-batch updates; CDC synchronization; multi-source wide table assemblyStream Load, Routine Load, Broker Load, INSERT INTO
DML update (UPDATE)Low-frequency, batch updates; conditional data refresh; cross-table associated updatesUPDATE, INSERT INTO ... SELECT ...

1.2.1 Update via ingestion (UPSERT)​

All ingestion methods (Stream Load, Broker Load, Routine Load, INSERT INTO) process data in the Unique Key model with UPSERT semantics by default:

  • If the primary key already exists: the old row is overwritten by the new row.
  • If the primary key does not exist: a new row is inserted.

Stream Load, Broker Load, Routine Load, and INSERT INTO apply UPSERT semantics to a VeloDB Cloud Unique Key table

The behavior of ingest-based updates differs across table models. For details, see:

1.2.2 Update via the UPDATE statement​

VeloDB Cloud supports the standard SQL UPDATE, which can update data in Unique Key model tables based on WHERE conditions and supports cross-table associated updates.

-- Simple update
UPDATE user_profiles SET age = age + 1 WHERE user_id = 1;

-- Cross-table associated update
UPDATE sales_records t1
SET t1.user_name = t2.name
FROM user_profiles t2
WHERE t1.user_id = t2.user_id;

The execution process of UPDATE is: first scan the data that meets the conditions, then write the updated rows back. This is suitable for low-frequency, batch update scenarios.

Warning:

High-concurrency UPDATE operations on data with the same primary key are not recommended. Concurrent UPDATE operations cannot guarantee data isolation when they involve the same primary key.

For the syntax, typical usage, and limitations of the UPDATE statement, see: Update Data with UPDATE.

1.2.3 Update via INSERT INTO SELECT​

Since the Unique Key model uses UPSERT semantics by default, using INSERT INTO ... SELECT ... can also achieve the effect of UPDATE, which is suitable for batch write-back from other tables.

1.3 Choose a deletion path​

VeloDB Cloud provides two data deletion paths, with different implementation mechanisms across table models:

Deletion PathSupported Table ModelsDescription
Marked deletion via ingestionUnique Key ModelWrites a __DORIS_DELETE_SIGN__ = 1 marker; background compaction later reclaims eligible obsolete versions
DML deletion (DELETE / TRUNCATE)All modelsDelete data by condition or empty a table/partition

For complete information, see Delete Data.

2. Understand Unique Key updates​

2.1 Compare Merge-on-Write and Merge-on-Read​

The Unique Key model has two data merging strategies. New Unique Key tables use Merge-on-Write by default unless you explicitly disable it. Existing Merge-on-Read tables keep their storage mode.

DimensionMerge-on-Write (MoW)Merge-on-Read (MoR, legacy)
Behavior on writeResolves duplicate keys on write and hides superseded versions from queriesRetains multiple versions on write
Query performanceClose to that of a Duplicate Key table without updatesMerges row versions during queries, adding query work
Write performanceResolves versions during ingestion, adding write workClose to a Duplicate Key table
Resource consumptionWrites and background Compaction consume more CPU/memoryQueries consume more CPU/memory
Applicable scenariosWorkloads that need efficient queries and partial column updatesWrite-heavy with infrequent reads (no longer recommended)

Use a Merge-on-Write Unique Key table for partial column updates.

2.2 Order updates with a Sequence column​

In a distributed system, data may arrive out of order. For example, an order status changes successively to "Paid" and "Shipped", but due to network latency, the "Shipped" message may arrive at VeloDB Cloud before the "Paid" message.

The Sequence column mechanism solves this problem: when creating the table, specify a column (typically a timestamp or version number) as the Sequence column. When writing data with the same primary key, VeloDB Cloud always retains the row with the largest Sequence value.

CREATE TABLE order_status (
order_id BIGINT,
status_name STRING,
update_time DATETIME
)
UNIQUE KEY(order_id)
DISTRIBUTED BY HASH(order_id)
PROPERTIES (
"function_column.sequence_col" = "update_time" -- Specify update_time as the Sequence column
);

-- 1. Write the "Shipped" record (larger update_time)
-- {"order_id": 1001, "status_name": "Shipped", "update_time": "2023-10-26 12:00:00"}

-- 2. Write the "Paid" record (smaller update_time, arrives later)
-- {"order_id": 1001, "status_name": "Paid", "update_time": "2023-10-26 11:00:00"}

-- Final result: the record with the largest update_time is retained
-- order_id: 1001, status_name: "Shipped", update_time: "2023-10-26 12:00:00"

See Control Concurrent Updates for details about Sequence columns, row visibility, and concurrent UPDATE statements.

2.3 Delete rows with delete markers​

__DORIS_DELETE_SIGN__ uses a "logical marker, background cleanup" approach, divided into three stages:

  1. Execute deletion: When data is deleted via ingestion or the DELETE statement, VeloDB Cloud does not immediately remove the data from physical files. The deletion is represented logically by a record with __DORIS_DELETE_SIGN__ set to 1; MoW also maintains delete bitmaps to hide superseded row versions.
  2. Filter deleted rows from queries: During queries, ordinary queries hide deleted rows. The delete-sign predicate __DORIS_DELETE_SIGN__ = 0 describes which logical rows remain visible, together with MoW delete-bitmap filtering where applicable.
  3. Reclaim obsolete versions through compaction: When the Compaction process detects that a primary key has both a normal record and a delete marker record, it can remove obsolete row versions when they are eligible for cleanup. Physical reclamation is asynchronous and depends on compaction and retained versions.

VeloDB Cloud hides rows marked with DORIS_DELETE_SIGN and later reclaims eligible obsolete versions

This diagram illustrates the delete-marker flow. Cleanup timing and query overhead depend on the workload and retained versions.

2.4 Update selected columns​

Unique Key tables with MoW support partial column updates: during ingestion, you only need to provide the primary key and the columns to be updated. Columns that are not provided retain their original values.

How to enable:

Ingestion MethodConfiguration to Enable
INSERT INTOSet the session variable enable_unique_key_partial_update = true
Stream LoadSet the partial_columns HTTP header to true

For fixed-column partial updates, keep MoW enabled:

CREATE TABLE user_profiles (
user_id BIGINT,
name STRING,
age INT,
last_login DATETIME
)
UNIQUE KEY(user_id)
DISTRIBUTED BY HASH(user_id)
PROPERTIES (
"enable_unique_key_merge_on_write" = "true"
);

-- Initial data
-- user_id: 1, name: 'Alice', age: 30, last_login: '2023-10-01 10:00:00'

-- Partial update via Stream Load, writing only age and last_login
-- {"user_id": 1, "age": 31, "last_login": "2023-10-26 18:00:00"}

-- Data after update
-- user_id: 1, name: 'Alice', age: 31, last_login: '2023-10-26 18:00:00'

In terms of implementation, partial column updates in the Unique Key model are not in-place updates. Instead, during ingestion, existing columns are read, missing fields are filled in, and the entire row is rewritten. This results in read amplification and write amplification: for example, when updating 10 fields of a 100-column wide table with similar field sizes, a simplified uncompressed model would read 9 MB of unchanged fields and write a 10 MB row for each 1 MB of changed fields. Actual I/O depends on caching, compression, and the table layout. This is an illustration, not a benchmark.

Performance recommendations:

RecommendationDescription
Size the cluster for the workloadPartial column updates read existing values and can increase I/O. Batch writes and monitor the cluster during representative loads
Enable row store for wide tablesFor very wide tables, enabling row store is recommended, so a single IO can read the entire row. In column store mode, each missing field requires a separate IO

For complete usage instructions (Stream Load, INSERT INTO, Flink Connector, etc.), see: Update Selected Columns.

3. Apply updates to common workloads​

3.1 Synchronize source changes with CDC​

Tools such as Flink CDC capture the Binlog of upstream databases (MySQL, PostgreSQL, Oracle, etc.) and write it to VeloDB Cloud Unique Key model tables.

Flink CDC sends source changes through a connector sink into a VeloDB Cloud Unique Key table

Key capabilities:

  • Synchronize an entire database: Flink Doris Connector internally integrates Flink CDC, enabling end-to-end whole-database synchronization without manual table creation or field mapping.
  • Handle change events: Configure these capabilities together with the connector's checkpoint and source-event ordering behavior:
    • The Unique Key model UPSERT handles INSERT / UPDATE.
    • __DORIS_DELETE_SIGN__ handles DELETE.
    • A Sequence column with an ordering value that distinguishes source changes handles out-of-order data. Equal Sequence values do not define a deterministic event order.

3.2 Assemble wide tables from multiple sources​

Using partial column updates, you can complete multi-source wide table assembly directly within VeloDB Cloud without performing real-time joins in Flink:

  1. Create a Unique Key model wide table.
  2. Different data sources (basic information, behavior logs, transaction data, etc.) write to it in real time via Stream Load / Routine Load.
  3. Each data stream writes only the columns it is responsible for, for example:
    • The user behavior stream updates page_view_count and last_login_time.
    • The transaction stream updates total_orders and total_amount.

Each stream sends only the columns it changes. The warehouse reads the missing values and rewrites the row. When independent streams share a key, coordinate event ordering in the source pipelines. A single Sequence column orders changes to the row as a whole.

4. Plan update workloads​

4.1 Optimize update workloads​

No.RecommendationDescription
1Prefer ingest-based updatesFor high-frequency, large-volume updates, prefer Stream Load and Routine Load over UPDATE DML
2Batch writesEach INSERT has transaction overhead. Batch small writes or consider Group Commit when its semantics fit your workload
3Use high-frequency DELETE on Duplicate/Aggregate models with cautionPredicate accumulation affects subsequent query performance
4Use TRUNCATE TABLE ... PARTITION to empty a partitionWhen deleting an entire partition, TRUNCATE TABLE ... PARTITION avoids row-by-row predicate deletion
5Execute UPDATE seriallyAvoid concurrent execution of UPDATE tasks that may operate on the same primary key

4.2 Coordinate updates in shared storage​

VeloDB Cloud separates compute from shared storage. MoW writes coordinate delete-bitmap updates through the Meta Service. Ingestion, compaction, and schema changes can contend for this metadata coordination.

VeloDB Cloud coordinates MoW writes and background operations through the Meta Service

To reduce contention:

  1. Batch writes: Combine small updates and control concurrent writers to the same table.
  2. Design partitions and buckets for the workload: Limit the partitions touched by each load and avoid excessive tablets. See partitioning and bucketing.
  3. Monitor update latency: If contention persists, contact VeloDB Cloud support. Compaction and service-level configuration are managed by VeloDB Cloud.

Update jobs consume cluster compute and can increase storage work. Test representative batches before scheduling large refreshes, and drop test tables when you no longer need them.

Enter to send · Shift+Enter for a new line