Repository navigation
perf(postgres): render compared views in one transaction per connection - #259
Merged
Merged
Conversation
…r connection Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Deciding whether a changed view is the same one rendered differently costs a fixed number of round trips again, not four per rendering.
Why. Each rendering was its own begin, create temporary view, read back and roll back. Across major versions the target renders two per view, so 200 views took about 1,600 round trips to the target: negligible locally, but over a 50 ms link a diff went from about 48 s to about 92 s.
Now.
dropEquivalentfirst collects every view body it will need, per connection: the source's own, the target's own, and the source's on the target across versions. It renders them in one transaction: a singleDOblock creates each temporary view under its own exception handler, so a body that can't be built only loses its own rendering, and the renderings go to a temporary table read back once. Everything is rolled back. Cached views skip the per-rendering transaction entirely. Other kinds (checks, indexes, policies, …) are unchanged, and anything the batch can't do falls back to the old one-by-one path.Tests
ViewRenderingRoundTripsPostgresTest: 25 changed views, half equivalent and half genuinely different, plus one that can't be built. The verdicts are as before, and the target sees fewer than 5 rolled-back transactions (master: 26). Skipped on PostgreSQL 14, which lackspg_stat_force_next_flush().CrossVersionPostgresTest,ExpressionEquivalencePostgresTest,BulkSchemaPostgresTestandViewGrantsRoundTripPostgresTestpass between PostgreSQL 16 and 15: 51 tests.🤖 Generated with Claude Code