Skip to content

Conversation

@tianzhou
Copy link
Contributor

Related #240

  • groupDiffs: merge three loops into one by tracking creates incrementally (diffs are topologically sorted, so creates come before dependent operations)
  • calculateSummaryFromSteps: remove pre-scan loop by determining parent type directly from step.Type prefix (table.index, view.index, materialized_view.index)

- groupDiffs: merge three loops into one by tracking creates incrementally
  (diffs are topologically sorted, so creates come before dependent operations)
- calculateSummaryFromSteps: remove pre-scan loop by determining parent type
  directly from step.Type prefix (table.index, view.index, materialized_view.index)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 15, 2026 04:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors two functions in the plan module to convert multi-pass loops into single-pass operations for improved performance and code simplicity.

Changes:

  • Merged three separate loops in groupDiffs into one by tracking creates incrementally
  • Eliminated a pre-scan loop in calculateSummaryFromSteps by determining parent type directly from the step.Type prefix
  • Updated comments to reflect the single-pass approach

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

// Single-pass: process all steps, determining parent type from step.Type prefix
// Sub-resource types encode their parent: "table.index", "view.index", "materialized_view.index"
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions "view.index" as a sub-resource type, but based on the DiffType constants in internal/diff/diff.go, views only have "view.comment" as a sub-resource. Regular views don't support indexes in PostgreSQL (only materialized views do). The comment should be updated to reflect the actual sub-resource types: "table.index", "view.comment", "materialized_view.index".

Copilot uses AI. Check for mistakes.
Views don't support indexes in PostgreSQL - only materialized views do.
Updated comment to show accurate examples: table.index, table.column,
view.comment, materialized_view.index.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tianzhou tianzhou merged commit 2a9ce19 into main Jan 15, 2026
2 checks passed
alecthomas pushed a commit to alecthomas/pgschema that referenced this pull request Jan 26, 2026
* refactor: convert multi-pass to single-pass in plan module

- groupDiffs: merge three loops into one by tracking creates incrementally
  (diffs are topologically sorted, so creates come before dependent operations)
- calculateSummaryFromSteps: remove pre-scan loop by determining parent type
  directly from step.Type prefix (table.index, view.index, materialized_view.index)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: correct comment about view sub-resource types

Views don't support indexes in PostgreSQL - only materialized views do.
Updated comment to show accurate examples: table.index, table.column,
view.comment, materialized_view.index.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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