Skip to content

docs: MySQL comparison, three-bucket cost model, binary-coercible type changes - #68

Merged
Kiran01bm merged 1 commit into
mainfrom
kiran01bm/docs-mysql-pg-comparison
Sep 2, 2026
Merged

docs: MySQL comparison, three-bucket cost model, binary-coercible type changes#68
Kiran01bm merged 1 commit into
mainfrom
kiran01bm/docs-mysql-pg-comparison

Conversation

@Kiran01bm

Copy link
Copy Markdown
Collaborator

Doc-only: adds the MySQL ↔ PostgreSQL comparison reference the docs already cite, a three-bucket cost model on top of the online-DDL reference, and a deep-dive on when ALTER COLUMN TYPE is a relabel versus a rewrite.

Why

Six places in docs/ link to a mysql-vs-postgresql.md that never existed in this repo, so the lock-queue explanation and the Spirit → PostgreSQL primitive mapping they lean on were unreachable. Separately, the online-DDL reference lists two axes (lock level, rewrite/scan) but never states the synthesis readers actually need — that every PostgreSQL DDL falls into one of three buckets that correspond to MySQL's INSTANT / INPLACE / COPY — and the binary-coercible verdict had a one-line definition with no account of how PostgreSQL decides or which changes only look free.

What

  • docs/mysql-vs-postgresql.md — new: how each engine expresses online DDL, lock-mode → MDL mapping, why DDL is dangerous (the lock-queue pile-up, same in both engines), Spirit → PostgreSQL primitive mapping.
  • docs/postgres-online-ddl-reference.md — new "three buckets" section (catalog-only ≈ INSTANT, full scan no rewrite ≈ INPLACE, full rewrite ≈ COPY) tied to the plan-report reason vocabulary; dangling refs turned into links.
  • docs/binary-coercible-type-changes.md — new: the structural rewrite test in ATColumnChangeRequiresRewrite, the four shapes that skip a rewrite and why, six categories of forced rewrite with examples, "looks free but rewrites" (shortening varchar, numeric scale/precision with row-level before/after, char(n)text, arrays, non-UTC timestamptimestamptz), what "no rewrite" still costs, catalog/filenode/event-trigger checks, and the exact rules the planner's binaryCoercible accepts.
  • Dangling 12-mysql-vs-postgresql.md / bare mysql-vs-postgresql references in design-principles.md, low-level-design.md, high-level-design.md, invariants.md now link to the real sections; docs/README.md table updated.

No code, contract, or capability changes.

Before / after

Before
  design-principles.md ─┐
  low-level-design.md  ─┤──▶ "12-mysql-vs-postgresql.md § ..."   (404 — file never existed)
  invariants.md        ─┤
  online-ddl-reference ─┘
  online-ddl-reference: axis 1 (lock) + axis 2 (rewrite/scan) ... no synthesis
  plan-report reasons:  metadata-only | binary-coercible | safer-idiom | type-rewrite ...
                        (no doc says which bucket each belongs to)

After
  design-principles.md ─┐
  low-level-design.md  ─┤──▶ mysql-vs-postgresql.md ──▶ § lock queue, § primitive mapping
  invariants.md        ─┤
  online-ddl-reference ─┘
  online-ddl-reference: ┌────────────────┬──────────────────────┬──────────────┐
                        │ catalog-only   │ full scan, no rewrite│ full rewrite │
                        │ ≈ INSTANT      │ ≈ INPLACE            │ ≈ COPY       │
                        │ native as-is   │ safer sequence       │ copy-and-swap│
                        └───────┬────────┴──────────────────────┴──────────────┘
                                └──▶ binary-coercible-type-changes.md
                                     (how PG decides; four free shapes;
                                      six rewrite categories; looks-free traps)

…e changes

Restore the MySQL vs PostgreSQL reference the other docs already cited but
never shipped, and name the three lock × work-done buckets (catalog-only /
full scan / full rewrite) that MySQL's ALGORITHM states map onto so the
plan-report reasons have a stated model behind them.
@Kiran01bm
Kiran01bm marked this pull request as ready for review September 2, 2026 07:28
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Kiran01bm
Kiran01bm merged commit a188c37 into main Sep 2, 2026
10 checks passed
Kiran01bm added a commit that referenced this pull request Sep 4, 2026
Follow-up corrections to the MySQL-comparison and binary-coercible docs
from #68: dependency refusals, temporal-precision rewrite reasons, the
complete planner-reason cost map, and dead design-doc references.

## Why
This commit was pushed to the #68 branch after the PR had merged, so it
never reached `main`. Its content fixes factual statements readers would
otherwise take as PostgreSQL behaviour: `ALTER COLUMN TYPE` on a column
a `STORED` generated column depends on is refused outright, temporal
precision reductions rewrite because the rounding survives, and the
planner-reason cost map needs to distinguish online forms that scan from
those that do not. It also replaces dead design-document references with
their live sources.

## What
- `binary-coercible-type-changes.md`: move the generated-column case
next to the view/rule refusal and correct the bucket-B/C wording for
rounding versus stored typmod. Only an `interval` **precision**
reduction rewrites; a field-only reduction (`DAY TO SECOND` → `HOUR TO
SECOND`) relabels and keeps stored components the new declared type
excludes, so it is listed with the assumptions that are wrong in the
safe direction.
- `postgres-online-ddl-reference.md`: map all planner reasons to their
cost buckets, distinguish the two `online-idiom` cost shapes — including
`ADD CONSTRAINT … USING INDEX`, catalog-only for a unique adoption and a
full scan when adopted as a primary key on a nullable column — and
surface dependency refusals beside the `binary-coercible` verdict.
- `low-level-design.md`, `high-level-design.md`, `design-principles.md`,
`invariants.md`, and `postgresql-version-support.md`: replace dead
references with the Spirit README, PostgreSQL primitive mapping, and
current implementation-status section.
- `plan-report.md` and `capabilities.md`: align the canonical reason and
support tables with planner behaviour and PostgreSQL's dependency
refusals.

## Before / after
```
Before (origin/main after #68)              After
generated column + ALTER TYPE:              generated column + ALTER TYPE:
  "not re-recorded; decided on own            "refused: cannot alter type of a column
   transform expression"                       used by a generated column"

interval field/precision reduction:         interval precision reduction: rewrites (bucket B)
  one cell, "rewrites"                      interval field-only reduction: relabels,
                                               stored components survive (safe-direction)

reasons -> buckets: incomplete/coarse       reasons -> buckets: complete, with online
                                               no-scan / full-scan / USING INDEX (conditional)

refs: nonexistent design notes              refs: Spirit README, PostgreSQL primitive
      and build-plan files                         mapping, current implementation status
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants