[Postgres] Avoid storing copy of replicated rows with REPLICA IDENTITY FULL #459
+893
−46
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.
Summary
Implements table-level
storeCurrentDataconfiguration for PostgreSQL REPLICA IDENTITY FULL optimization, eliminating the need to store raw row data when complete rows are always available through replication.Problem
Previously, PowerSync used a global
storeCurrentDatasetting that applied uniformly across all tables in a database. PostgreSQL tables configured withREPLICA IDENTITY FULLalways send complete row data in replication events, making thecurrent_datacollection redundant for these tables and wasting storage.Solution
Made
storeCurrentDataa table-level property that's automatically determined during table resolution:REPLICA IDENTITY FULLand setsstoreCurrentData = falsestoreCurrentData = true(existing behavior)Changes
Core API Changes
SourceEntityDescriptorwith optionalreplicationIdentityfieldstoreCurrentDataproperty toSourceTableclassPostgreSQL Module
WalStreamnow extracts and passesreplicationIdentityfrom replication inforesolveTablePostgreSQL Storage
PostgresBucketBatchnow checkssourceTable.storeCurrentDataper-record instead of using global settingcurrent_datafor tables that need itMongoDB Storage
storeCurrentDatabased onreplicationIdentitysource_tablescollection for persistenceTesting
Performance Impact
For PostgreSQL tables with
REPLICA IDENTITY FULL:current_dataentries)Backward Compatibility
✅ Fully backward compatible:
storeCurrentData = truefor all non-FULL tablesDatabase Support