-
Notifications
You must be signed in to change notification settings - Fork 701
Description
Change Request
Please answer the following questions before submitting your issue. Thanks!
- Describe what you find is inappropriate or missing in the existing docs.
https://docs.pingcap.com/tidb/stable/ticdc-sink-to-mysql/
- Describe your suggestion or addition.
"Multi-update" is an optimization in TiCDC to merge multiple similar UPDATE statement into a single statement:
UPDATE tbl SET a = 1, b = 2 WHERE pk = 3;
UPDATE tbl SET a = 4, b = 5 WHERE pk = 6;
UPDATE tbl SET a = 7, b = 8 WHERE pk = 9;
-- becomes:
UPDATE tbl SET
a = CASE WHEN pk = 3 THEN 1 WHEN pk = 6 THEN 4 WHEN pk = 9 THEN 7 END,
b = CASE WHEN pk = 3 THEN 2 WHEN pk = 6 THEN 5 WHEN pk = 9 THEN 8 END
WHERE pk IN (3, 6, 9);
The transformation is disabled when the update statement is too large, as the complexity outweighs the cost of having multiple statements. The threshold of "large" can be controlled by the parameter max-multi-update-row-size
:
docs/ticdc/ticdc-sink-to-mysql.md
Line 69 in f16197f
| `max-multi-update-row-size` | The size limit of `UPDATE ROWS` SQL statements executed to the downstream when batch write (`batch-dml-enable`) is enabled. If the size exceeds this limit, each row is executed as a separate SQL statement (optional, the default value is `1024`, and the maximum value is `8192`). | |
The size limit of
UPDATE ROWS
SQL statements executed to the downstream when batch write (batch-dml-enable
) is enabled. If the size exceeds this limit, each row is executed as a separate SQL statement.
This description suggested the limit is measuring that of the combined "UPDATE SET CASE WHEN" statement. But in reality, this is actually measuring the per-row size before batching. The misunderstanding causes customer confusion, because they are seeing huge batched UPDATE statements downstream with length over 20 KiB despite max-multi-update-row-size
is kept as the default 1 KiB.
- Provide some reference materials (such as documents and websites) if you could.
CDC source code