Schemas and Connections

Postgres Schemas

When no schema is specified, the Postgres public schema is used for every query. A different schema can be specified as a prefix:

-- Note: the schema must be in double quotes
SELECT * FROM "other"."assets"

High availability / Replicated databases

When the source database is replicated, for example with Amazon RDS Multi-AZ deployments, specify a single connection with multiple host endpoints. Each host endpoint will be tried in sequence, with the first available primary connection being used.

For this, each endpoint must point to the same physical database, with the same replication slots. This is the case when block-level replication is used between the databases, but not when streaming physical or logical replication is used. In those cases, replication slots are unique on each host, and all data would be re-synced in a fail-over event.

Multiple separate connections

PowerSync can be configured with multiple separate connections, where each connection is concurrently replicated. Do not add multiple connections to multiple replicas of the same database — this would cause data duplication. Only use this when the data on each connection does not overlap.

Each connection can be configured with a "tag", to distinguish these connections in sync rules. The same tag may be used for multiple connections (if the schema is the same in each).

By default, queries reference the "default" tag. To use a different connection or connections, assign a different tag, and specify it in the query as a schema prefix. In this case, the schema itself must also be specified.

-- Note the usage of quotes here
SELECT * FROM "secondconnection.public"."assets"

Last updated