-
Notifications
You must be signed in to change notification settings - Fork 25
Postgres Bucket Storage #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
…point should be coalesced when committing updates.
🦋 Changeset detectedLatest commit: 780770b The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 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 |
1 task
rkistner
reviewed
Jan 13, 2025
modules/module-postgres-storage/src/migrations/scripts/1684951997326-init.ts
Outdated
Show resolved
Hide resolved
rkistner
reviewed
Jan 13, 2025
modules/module-postgres-storage/src/storage/batch/PostgresBucketBatch.ts
Outdated
Show resolved
Hide resolved
rkistner
reviewed
Jan 14, 2025
modules/module-postgres-storage/src/storage/PostgresBucketStorageFactory.ts
Outdated
Show resolved
Hide resolved
rkistner
reviewed
Jan 14, 2025
modules/module-postgres-storage/src/storage/PostgresBucketStorageFactory.ts
Outdated
Show resolved
Hide resolved
modules/module-postgres-storage/src/storage/PostgresSyncRulesStorage.ts
Outdated
Show resolved
Hide resolved
modules/module-postgres-storage/src/storage/batch/PostgresBucketBatch.ts
Outdated
Show resolved
Hide resolved
rkistner
previously approved these changes
Jan 14, 2025
rkistner
previously approved these changes
Jan 15, 2025
Chriztiaan
approved these changes
Jan 15, 2025
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.
Overview
In some circumstances configuring a Postgres server for bucket storage might be simpler than a MongoDB replica set.
This PR introduces a new
@powersync/service-module-postgres-storagemodule which registers the ability to use a Postgres database for sync bucket storage.See the readme for some additional context.
Testing
The Postgres storage implementation currently passes all unit tests. Tests include the shared storage unit tests from
@powersync/service-core-testsand the replicator tests for all the current replication modules where Postgres is used in addition to MongoDB as a storage provider.This has also been tested in an application demo environment in the new Postgres Bucket storage self host demo from powersync-ja/self-host-demo#45.
Basic performance comparisons between MongoDB were made for testing purposes only. Running locally on an M1 Mac, an initial replication of 2 million rows was timed. Initial replication took 4 minutes and 20 seconds for Postgres and 3 minutes 59 seconds for MongoDB.
Memory allocations were monitored using a debugger while doing initial replication and streaming data to clients. No noticeable memory leaks were found.
Future work
Some of the storage implementation classes duplicate minor implementation between them. These could be improved by using abstract classes at some stage.
There is room for performance optimisations for both reads and writes. E.g. when using the
test-clienttofetch-operationsfor 2.5 million rows of a single global bucket on an M3 Macbook it takes about 25 seconds for MongoDB to respond with all the data, while Postgres takes 75 seconds.