Is there an existing issue for the same feature request?
Summary
REPLACE INTO in MatrixOne has two execution paths with significant issues in semantics, performance, and correctness.
Current Problems
Legacy Path Issues
- Suspicious DELETE conditions: Legacy path constructs DELETE conditions via string concatenation.
buildConjunction() can generate col = NULL conditions with questionable semantics.
- Non-atomic execution: Legacy path executes two separate SQL statements (DELETE then INSERT) in scope.go, not a single operator with atomic semantics.
Modern Path Issues
- Multiple table/index scans: Modern path scans the main table multiple times. Each unique index triggers additional DEDUP JOIN and old-rowid LEFT JOIN operations.
- Concurrency concerns: LOCK_OP comes late in the pipeline. Potential race conditions under high concurrency need targeted stress testing.
- Partition handling:
PartitionNames exists in parser but is not consumed in REPLACE planning.
Missing Test Coverage
- NULL value handling
- High-concurrency scenarios
- Partition table cases
Performance Concerns
- Modern path overhead: Main table scanned at least 2x. Each unique index amplifies join and lock target complexity.
- Legacy path overhead: String construction, SQL re-parsing, and dual-execution costs.
Proposed Improvements
Short-term (High Value)
- Eliminate legacy fallback path, unify to operator-based execution.
Medium-term
- Create a dedicated REPLACE operator that reuses
initInsertReplaceStmt / MULTI_UPDATE logic.
- Maintain delete+insert semantics, avoid direct ODKU substitution.
Long-term (Optimal)
- Push conflict detection + delete + insert down to storage/txn layer for true atomic replace.
Additional Context
Related: PK/UK/FK/CTE/vector-index test cases exist, but NULL/concurrency/partition tests are missing.
What type of PR is this?
Is there an existing issue for the same feature request?
Summary
REPLACE INTO in MatrixOne has two execution paths with significant issues in semantics, performance, and correctness.
Current Problems
Legacy Path Issues
buildConjunction()can generatecol = NULLconditions with questionable semantics.Modern Path Issues
PartitionNamesexists in parser but is not consumed in REPLACE planning.Missing Test Coverage
Performance Concerns
Proposed Improvements
Short-term (High Value)
Medium-term
initInsertReplaceStmt/MULTI_UPDATElogic.Long-term (Optimal)
Additional Context
Related: PK/UK/FK/CTE/vector-index test cases exist, but NULL/concurrency/partition tests are missing.
What type of PR is this?