Skip to content

perf(Schema): batch table introspection queries - #262

Merged
roxblnfk merged 2 commits into
2.xfrom
feat/batch-introspection-queries
Aug 11, 2026
Merged

perf(Schema): batch table introspection queries#262
roxblnfk merged 2 commits into
2.xfrom
feat/batch-introspection-queries

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Aug 11, 2026

Copy link
Copy Markdown
Member

🔍 What was changed

  • Table introspection batches its catalogue queries: CHECK/DEFAULT constraints and enum ranges are read once per table instead of once per column, and the index query is shared between fetchIndexes() and fetchPrimaryKeys(). Introspecting a 40-column table drops from dozens of round trips to a handful.
  • New AbstractTable::resetIntrospectionCache() hook clears the memoized state before a schema is read and after DDL is applied.
  • Postgres native enums resolve by type schema and name via pg_enum instead of enum_range() over the search_path. This fixes three bugs of the old text-based parsing:
    • a column typed with an enum from another schema picked up the values of a same-named type;
    • labels containing commas or quotes ('a,b', 'it''s') were split incorrectly — they are now returned verbatim;
    • an enum type without labels was reported as an enum with a single empty-string value — it is no longer treated as an enum.

The per-column queries stay as a fallback: the new createInstance() arguments are optional, so third-party callers are unaffected.

Why?

Introspection cost one query per column and per constraint, which dominates schema sync against a remote database.

Checklist

fix(Postgres): resolve native enum values by type schema — an enum type outside the search_path resolved to a same-named type instead

Introspection issued a query per column and per constraint, so a wide table cost
dozens of round trips. Constraints are now fetched once per table and dispatched
in PHP, and the index query is shared between fetchIndexes() and
fetchPrimaryKeys(); AbstractTable::resetIntrospectionCache() drops that state
before a read and after DDL.

The per-column queries stay as a fallback: the new createInstance() arguments are
optional, so third-party callers are unaffected.

Assisted-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.99099% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.48%. Comparing base (71a0a7f) to head (9648039).

Files with missing lines Patch % Lines
src/Driver/SQLServer/Schema/SQLServerColumn.php 54.54% 10 Missing ⚠️
src/Driver/Postgres/Schema/PostgresColumn.php 64.00% 9 Missing ⚠️
src/Driver/Postgres/Schema/PostgresTable.php 98.48% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x     #262      +/-   ##
============================================
- Coverage     95.73%   95.48%   -0.26%     
- Complexity     2078     2119      +41     
============================================
  Files           141      141              
  Lines          5862     5974     +112     
============================================
+ Hits           5612     5704      +92     
- Misses          250      270      +20     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…m types

The batched pg_enum lookup returns labels with commas, quotes and spaces
verbatim, and reports a label-less enum column as a non-enum; the former
enum_range() text parsing mangled both cases.

Assisted-By: Claude Fable 5 (1M context) <noreply@anthropic.com>
@roxblnfk
roxblnfk merged commit 7e2d488 into 2.x Aug 11, 2026
29 of 31 checks passed
@roxblnfk
roxblnfk deleted the feat/batch-introspection-queries branch August 11, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant