[Bug]: v4.2.9 point DELETE on million-row tables scans all secondary-index tables
Maintainers usually reply within 1 day
@matrix-meow is already working on this.
Since Nov 26, 2026.
Assessment
This issue has not been assessed yet.
Description
Is there an existing issue for the same bug?
- I searched existing issues. #31618 reports secondary-index-maintenance scans for a bounded
DELETE ... LIMIT 1000on v4.2.5 with a synthetic fixture. This report adds a v4.2.9 witness with production QA table sizes and latencies, selective 4-5 row deletes, several secondary indexes per table, and full-primary-key DELETE controls. #32221 covers the related UPDATE path and does not establish DELETE behavior.
Environment
VERSION():8.0.30-MatrixOne-v4.2.9GIT_VERSION():6c05e42f9fBUILD_VERSION():2026-11-26 06:32:38- Managed QA cluster, real application tables. Resource identifiers below are replaced with placeholders.
- Measurements and plans were captured on 2026-11-26.
Actual behavior
Deleting only a few matching rows from tables with 1.46-1.89 million rows takes 4.0-8.2 seconds per DELETE statement.
EXPLAIN DELETE produces Multi Update -> Lock and a nested series of Table Scan operators on the hidden secondary-index tables, joined back to the base table. The shape occurs for both secondary-index predicates and full-primary-key predicates.
Table sizes
Sizes are from SHOW TABLE STATUS; total size is Data_length + Index_length converted to GiB.
| Table | Rows | Data | Indexes | Total | Secondary indexes |
|---|---|---|---|---|---|
mowl_node_execution_snapshot |
1,893,530 | 2.321 GiB | 1.529 GiB | 3.850 GiB | 4 |
mowl_case_token_snapshot |
1,894,957 | 0.603 GiB | 1.644 GiB | 2.247 GiB | 5 |
mowl_trace_span |
1,458,422 | 0.405 GiB | 0.641 GiB | 1.045 GiB | 4 |
Actual SQL and timings
The following SQL shapes were executed by the application. rows_read and durations are from system.statement_info for successful statements.
DELETE FROM `mowl_node_execution_snapshot`
WHERE `workspace_id` = 'ws' AND `branch_id` = 'branch';
DELETE FROM `mowl_case_token_snapshot`
WHERE `workspace_id` = 'ws' AND `branch_id` = 'branch';
DELETE FROM `mowl_trace_span`
WHERE `trace_id` = 'trace';
| Table | statement_info.rows_read |
First duration | Second duration |
|---|---|---|---|
mowl_node_execution_snapshot |
4 | 5.884 s | 7.859 s |
mowl_case_token_snapshot |
4 | 8.009 s | 8.207 s |
mowl_trace_span |
5 | 5.072 s | 4.021 s |
The three statements account for 18.965-20.087 seconds across two separate runs. Each run used different resource IDs and the same SQL shapes.
Relevant index definitions
Non-key columns are omitted; these are the exact key definitions from SHOW INDEX.
mowl_node_execution_snapshot:
PRIMARY KEY (node_execution_id)
INDEX idx_nes_branch (branch_id)
INDEX idx_nes_case (case_id)
INDEX idx_nes_workitem (case_id, runtime_workitem_task_id)
INDEX idx_nes_activation (case_id, activation_id)
mowl_case_token_snapshot:
PRIMARY KEY (token_snapshot_id)
INDEX idx_cts_branch (branch_id)
INDEX idx_cts_case (case_id)
INDEX idx_cts_token (case_id, token_id)
INDEX idx_cts_from_node (from_node_execution_id)
INDEX idx_cts_activation (case_id, activation_id)
mowl_trace_span:
PRIMARY KEY (span_id)
INDEX idx_trace_id (trace_id)
INDEX idx_case_id (case_id)
INDEX idx_parent_span_id (parent_span_id)
INDEX idx_started_at (started_at)
Steps to reproduce
Run these read-only EXPLAIN statements against tables with the schema and scale above:
EXPLAIN DELETE FROM `mowl_node_execution_snapshot`
WHERE `workspace_id` = 'ws' AND `branch_id` = 'branch';
EXPLAIN DELETE FROM `mowl_case_token_snapshot`
WHERE `workspace_id` = 'ws' AND `branch_id` = 'branch';
EXPLAIN DELETE FROM `mowl_trace_span`
WHERE `trace_id` = 'trace';
-- Full-primary-key controls:
EXPLAIN DELETE FROM `mowl_case_token_snapshot`
WHERE `token_snapshot_id` = 'pk';
EXPLAIN DELETE FROM `mowl_trace_span`
WHERE `span_id` = 'pk';
Secondary-index predicate plan
The five-secondary-index table produces five hidden-index Table Scan nodes:
Multi Update
-> Lock
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.case_id, mowl_case_token_snapshot.activation_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.case_id, mowl_case_token_snapshot.token_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.case_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.branch_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.from_node_execution_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INDEX
Join Cond: (mowl_case_token_snapshot.token_snapshot_id = __mo_index_pri_col)
-> Table Scan on mowl_case_token_snapshot [ForceOneCN]
Filter Cond: (branch_id = 'branch'), (workspace_id = 'ws')
-> Index Table Scan on mowl_case_token_snapshot.idx_cts_branch [ForceOneCN]
The four-secondary-index tables show the same pattern with four hidden-index Table Scan nodes.
Full-primary-key control plan
Changing the predicate to the full primary key does not remove the index-maintenance scans:
Multi Update
-> Lock
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.case_id, mowl_case_token_snapshot.activation_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.case_id, mowl_case_token_snapshot.token_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.case_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.branch_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Join
Join Type: INNER
Join Cond: (__mo_index_idx_col = serial_full(mowl_case_token_snapshot.from_node_execution_id, mowl_case_token_snapshot.token_snapshot_id))
-> Table Scan on __mo_index_secondary_...
-> Table Scan on mowl_case_token_snapshot
Filter Cond: (token_snapshot_id = 'pk')
EXPLAIN DELETE FROM mowl_trace_span WHERE span_id = 'pk' likewise retains all four hidden-index Table Scan nodes.
Expected behavior
After locating a small set of rows, DELETE index maintenance should selectively locate and update the corresponding secondary-index entries while preserving atomicity and correctness. The physical work should scale with the matched rows and required index updates, rather than requiring unselective scans of unrelated index entries on million-row tables.
Removing useful read indexes is not a general solution. The full-primary-key controls demonstrate that rewriting the predicate alone does not address the index-maintenance plan.
Impact
Workflow deletion issues these statements as part of its data cleanup. Individual statements that touch only 4-5 rows take several seconds, making user-visible deletion operations take tens of seconds. The same plan shape can affect other selective cleanup paths on indexed tables.
Scope and related issues
- The timings above are from actual successful DML recorded in
system.statement_info. - The displayed plans are from
EXPLAIN, notEXPLAIN ANALYZE; per-hidden-indexinputRowsand physical I/O were not captured. This report therefore does not claim an exact number of index rows or disk blocks read during the production DELETEs. - #31618: bounded DELETE index-maintenance scan on v4.2.5 with a synthetic reproduction.
- #32221: single-row primary-key UPDATE index-maintenance scan; its fix and verification are scoped to UPDATE.
- #32066: secondary-index-predicated DML is also marked
ForceOneCN; this may be related to the driving scans, while the primary-key controls here isolate the separate index-maintenance shape.
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 312
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 736
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matrixorigin/matrixone
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
matrixorigin/matrixone#33363 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
matrixorigin/matrixone#33362 ·
Maintainers usually reply within 1 day
-
SLEEP rejects NULL and negative durations that MySQL acceptsPossibly taken @XuPeng-SH claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
matrixorigin/matrixone#32653 ·
Maintainers usually reply within 1 day
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in matrixorigin/matrixone
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zalando/postgres-operator#3257 ·
Maintainers usually reply within 2 days
-
[inputs.internal] README lists go_version tag on internal_gather instead of internal_agentPossibly taken @cvas22 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
influxdata/telegraf#20264 ·
Maintainers usually reply within 1 day
-
[Bug] Standalone migration breaks existing Ingress routes using the envoy-http Service port nameOpenaccepted bug wg/enterprise-environment
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/semantic-router#7483 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
stacklok/toolhive-catalog#2076 ·
Maintainers usually reply within 1 day