Skip to content

Collect catalog and statistics observations - #5

Merged
roachitect-aman merged 1 commit into
mainfrom
task-5-catalog-observations
Aug 25, 2026
Merged

Collect catalog and statistics observations#5
roachitect-aman merged 1 commit into
mainfrom
task-5-catalog-observations

Conversation

@roachitect-aman

Copy link
Copy Markdown
Contributor

Task 5 of the MVP plan.

Adds the seven catalog queries the profile is built from — relation row and size estimates, columns with their types, per-column statistics, extended statistics, foreign keys, indexes. None reads a user table: row counts come from pg_class.reltuples, distributions from pg_stats as PostgreSQL already computed them.

Rejects unsupported layouts early. Partitioned and inherited tables abort after the first two queries, before the other five run. A partitioned parent's reltuples is not the sum of its children, so a fan-out derived from one is silently wrong — worse than refusing.

Raw values never reach a serialized type. The collector dataclasses hold PostgreSQL's own encodings, including raw MCVs and histogram bounds, and none of them is written. Tokenization and normalization map them onto the contract types in later tasks.

parse_pg_array is a real parser. PostgreSQL quotes and backslash-escapes elements containing punctuation; a split(",") would corrupt exactly the values that matter most, silently.

Type support is an allowlist. Anything not enumerated is reported unsupported. A false negative costs an investigation; a false positive costs a failed cutover.

pg_inherits joins the --check-safety relation allowlist alongside the collector that reads it, per the house rule.

Verification: 157 tests pass, --check-safety clean over 9 SQL constants, ruff check clean, 3.9 grammar verified.

Adds the seven catalog queries the profile is built from: relation row and
size estimates, columns with their types, per-column statistics, extended
statistics, foreign keys and indexes. None of them reads a user table; row
counts come from pg_class.reltuples and distributions from pg_stats as
PostgreSQL already computed them.

Partitioned and inherited tables are rejected before the remaining queries
run. A partitioned parent's reltuples is not the sum of its children, so a
fan-out estimate derived from one would be silently wrong -- worse than
refusing to produce a profile.

Raw statistic values land in collector-local dataclasses that are never
serialized. Tokenization and normalization map them onto the contract types
in later changes.

pg_inherits joins the --check-safety relation allowlist alongside the
collector that reads it.

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@roachitect-aman
roachitect-aman merged commit 129731d into main Aug 25, 2026
7 checks passed
@roachitect-aman
roachitect-aman deleted the task-5-catalog-observations branch August 25, 2026 00:31
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.

1 participant