Skip to content

to 4.0: optimize data branch merge apply execution#24858

Open
gouhongshen wants to merge 2 commits into
matrixorigin:4.0-devfrom
gouhongshen:codex/data-branch-merge-exec-route
Open

to 4.0: optimize data branch merge apply execution#24858
gouhongshen wants to merge 2 commits into
matrixorigin:4.0-devfrom
gouhongshen:codex/data-branch-merge-exec-route

Conversation

@gouhongshen
Copy link
Copy Markdown
Contributor

@gouhongshen gouhongshen commented Jun 5, 2026

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Related issue #24099

What this PR does / why we need it:

DATA BRANCH MERGE materializes row differences into __mo_diff_* helper tables, then applies them to the base table with base-table DML that reads those helper tables.

runSql previously routed every statement mentioning __mo_diff_* through BackgroundExec. That was needed for temp-table DDL and temp-table-targeting DML, but it was too broad for the base-table delete/insert apply statements. On a 100M-row table with only 1000 updated rows, the apply phase spent seconds on the slower path.

This change keeps BackgroundExec for data-branch temp table DDL and DML that targets __mo_diff_* tables, while allowing base-table DML that only reads those helper tables to use the internal SQL executor.

Validation:

  • CGO_CFLAGS="-I$(pwd)/thirdparties/install/include" go test ./pkg/frontend
  • Built Docker image from the final patch and ran ./run.sh -p /Users/ghs-mo/MOWorkSpace/matrixone-2nd/test/distributed/cases/ -i git4data/branch: TOTAL 2968, SUCCESS 2968, FAILED 0, report/error.txt empty
  • 100M-row manual benchmark before final patch promotion: merge with 1000 updated rows dropped from ~2.13s server time to ~219ms server time

@mergify mergify Bot requested a review from XuPeng-SH June 5, 2026 04:00
@mergify mergify Bot added kind/bug Something isn't working kind/enhancement kind/test-ci labels Jun 5, 2026
@gouhongshen gouhongshen changed the title [codex] optimize data branch merge apply execution to 4.0: optimize data branch merge apply execution Jun 5, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jun 5, 2026
@gouhongshen gouhongshen marked this pull request as ready for review June 5, 2026 04:58
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@gouhongshen gouhongshen marked this pull request as ready for review June 5, 2026 09:45
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/enhancement kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants