Skip to content

[Bug][Performance] SF100 ALTER TABLE ADD COLUMN scales sharply with existing column count #29706

Open

Description

@daviszhen

Summary

On MatrixOne commit 77dbf5464466b1d5ae784e7d17d92cd1c1c8d17d, a single isolated ALTER TABLE ... ADD COLUMN on the SF100 order_line table takes about 11 seconds even with no concurrent workers. The measured ALTER time increases substantially as the number of existing columns increases.

This issue is requesting an R&D investigation of the execution path and expected performance characteristics. The current evidence is consistent with substantial physical data processing, but does not by itself prove a full-table rewrite.

Environment

  • MatrixOne commit: 77dbf5464466b1d5ae784e7d17d92cd1c1c8d17d
  • Host: srv-128, 64 vCPU, approximately 270 GB RAM
  • Dataset: SF100, order_line contains 30,000,000 rows
  • Benchmark branch: codex/p0-2-git4data-concurrency
  • Diagnostic workflow: schema_ddl_diagnostic
  • Execution: 1 worker, 1 step, isolated branch, no concurrent DDL, no evaluation query, no merge
  • P0-4 storage measurement: actual MatrixOne /mo-data mount; dump-cache excluded

Reproduction shape

After loading the SF100 dataset, the diagnostic workflow creates N extra columns before the timed operation, then measures only the target operation:

-- N preparation columns are created outside the target timing.
ALTER TABLE order_line ADD COLUMN g4d_probe_existing_0 BIGINT;

-- This statement is timed independently.
ALTER TABLE order_line ADD COLUMN g4d_probe_target_0 BIGINT;

The target column is added on an isolated branch. The diagnostic mode does not include agent concurrency, evaluation queries, or merge time.

Results

MatrixOne ALTER-only results

Extra existing columns before target ALTER Target ALTER (s) Preparation time (s) Target columns before/after
0 11.313 0.000 10 / 11
10 19.713 18.498 20 / 21
100 92.690 88.028 110 / 111
1000 800.691 747.260 1010 / 1011

The measured target time is strongly dependent on the existing column count. Across these four points it is approximately linear in the total column count, rather than constant; more data points and repetitions are needed before making a stronger complexity claim.

ALTER versus UPDATE

  • MatrixOne update_only, 0 extra columns: UPDATE 0.011654 s (run 37755245793)
  • MatrixOne alter_update, 0 extra columns: ALTER 11.365910 s, UPDATE 0.050516 s (run 37755744401)

This isolates the dominant cost in the ALTER operation rather than the accompanying UPDATE.

Reproducible benchmark runs

All listed runs completed successfully and passed the P0-4 completeness gate. MatrixOne used the pinned commit above.

Storage evidence

The P0-4 database-directory snapshots showed the following approximate growth during the isolated diagnostic workload:

Extra existing columns /mo-data growth
0 +0.42 GB
10 +1.22 GB
100 +2.29 GB
1000 +4.32 GB

This is evidence that the operation causes substantial physical storage activity, but the snapshots alone cannot distinguish data rewrite from flush/compaction or other storage-side effects.

DoltDB control

Using the same diagnostic harness, DoltDB target ALTER times were approximately 0.00137s, 0.00171s, 0.00258s, and 0.01534s for 0/10/100/1000 extra columns. This is not intended as a direct product comparison, but it suggests that the benchmark harness overhead is not the primary source of the MatrixOne delay.

Questions for R&D

  1. Does ALTER TABLE ... ADD COLUMN on this table execute a full or partial data rewrite/copy, or another physical operation? Please identify the relevant execution path.
  2. Why does the target ALTER time grow from 11.3s to 800.7s as the existing column count grows?
  3. Is the observed storage growth expected? Can it be attributed to rewrite, flush, compaction, versioned data, or another mechanism?
  4. Is this performance expected for the current MatrixOne architecture? Are there known optimizations, configuration changes, or recommended workarounds?
  5. If this is an inherent cost, what scale/column-count limitations should be documented for workloads that evolve schema repeatedly?
  6. Separately, can the historical high-concurrency failures be explained by lock/connection/timeout behavior? The present diagnostic runs are intentionally single-worker and do not answer that concurrency question.

Related issues

Requested outcome

Please confirm whether this behavior is expected. If not, please provide a fix or optimization plan; if yes, please document the execution/storage implications and recommended limits for repeated ADD COLUMN operations.

Detailed DoltDB control results

DoltDB was tested with the same schema_ddl_diagnostic protocol, SF100 dataset, 1 worker, 1 step, isolated branch, no evaluation query, and no merge. The target ALTER timing was measured independently from the preparation of the extra columns.

Extra existing columns before target ALTER Preparation time (s) Target ALTER (s) Target columns before/after Run
0 0.000000 0.001374 10 / 11 37756188657
10 0.006069 0.001710 20 / 21 37756402153
100 0.094330 0.002584 110 / 111 37756623451
1000 5.768475 0.015344 1010 / 1011 37756839649

The DoltDB update_only control with 0 extra columns took 0.002149 s (run 37757050699). Its alter_update control took 0.002155 s for ALTER and 0.002353 s for UPDATE (run 37757271500). All six DoltDB runs passed the P0-4 completeness gate.

For reference, the MatrixOne/DoltDB target ALTER timings under this protocol were:

Extra existing columns MatrixOne ALTER (s) DoltDB ALTER (s)
0 11.313 0.001374
10 19.713 0.001710
100 92.690 0.002584
1000 800.691 0.015344

This is a controlled benchmark comparison, not a claim that the two engines have identical storage or branch semantics. It does show that the delay is specific to the MatrixOne ALTER execution path rather than the common benchmark harness or the SQL client call itself.

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions