[Postgres] Skip redundant current_data copies for REPLICA IDENTITY FULL#655
Open
joshuabrink wants to merge 4 commits into
Open
[Postgres] Skip redundant current_data copies for REPLICA IDENTITY FULL#655joshuabrink wants to merge 4 commits into
joshuabrink wants to merge 4 commits into
Conversation
added 4 commits
May 29, 2026 10:42
… regression tests
🦋 Changeset detectedLatest commit: 65ca4e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
rkistner
reviewed
Jun 1, 2026
Contributor
rkistner
left a comment
There was a problem hiding this comment.
Before I did too far into the details - is there a way to do this that would avoid persisting the store_current_data flag on the SourceTable?
If that's not feasible, we should look into a more generic way of storing db-specific metadata on the SourceTable - I know we have another similar requirement for persisting MSSQL change capture instances - cc @Rentacookie.
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.
Re-implements #459 (which resolves #398)
Tables with
REPLICA IDENTITY FULLalways send the complete row on every change, so PowerSync's per-row copy incurrent_datais redundant for them. This makesstore_current_dataa per-table flag rather than a global one, skipping the copy (and the TOAST-merge read) for FULL tables while keeping it for every other replica identity.What changed
The source reports a source-agnostic
sendsCompleteRowson the entity descriptor (true only for FULL in Postgres), andresolveStoreCurrentDatain service-core derives the stored flag from it: reported true = no copy, reported false = keep a copy, unreported = preserve the persisted value. Keeping the resolution in core means the storage backends don't each re-derive the three-state logic.The flag is resolved during table resolution and re-evaluated on every
pgoutputRelation message, so a mid-streamALTER TABLE ... REPLICA IDENTITYis picked up without a re-snapshot. Reverting FULL to DEFAULT correctly falls back to a targeted resnapshot for any row that can no longer be completed from storage.Compatibility
Backward compatible, the column defaults to NULL (treated as true), and existing FULL tables pick up the optimization on their next DML or
ALTER. No re-snapshot required on upgrade.Testing
E2E tests in
module-postgrescover both ALTER directions (including TOAST recovery), andmodule-mongodb-storagecovers the storage-layer flag for v1 and v3.AI Usage
This PR was AI-assisted (Claude Code), manually directed, reviewed, and tested.