Commit 6d0ead2
feat: merge-DML batching optimization for binlog apply
Add --is-merge-dml-event flag that batches and deduplicates binlog DML
events before applying them to the ghost table, significantly reducing
SQL round-trips during high-write migrations.
When enabled and the unique key is memory-comparable (numeric columns):
- Deduplicates DML events by unique key (latest event wins)
- Reduces INSERT+DELETE sequences to DELETE (safe against row-copy races)
- Batches INSERTs/UPDATEs as multi-row REPLACE INTO
- Batches DELETEs as DELETE WHERE (pk) IN (...)
- Skips events beyond migration range (not yet copied by row-copy)
- Disables merge for tables with secondary unique indexes
Safety: strict numeric type validation in formatNumericValue prevents
SQL injection. Type detection uses exact base-type parsing (not substring).
Uses BuildColumnsPreparedValues for proper per-column conversion tokens.
Original implementation by shaohoukun in PR #1378, adapted to current
master's builder-pattern API with correctness and security hardening.
Co-authored-by: shaohoukun <shaohoukun@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 154d214 commit 6d0ead2
9 files changed
Lines changed: 840 additions & 65 deletions
File tree
- doc
- go
- base
- cmd/gh-ost
- logic
- sql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
161 | 173 | | |
162 | 174 | | |
163 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
214 | 215 | | |
| 216 | + | |
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
0 commit comments