Pgx: Replication Example ?

Created on 3 Feb 2019  路  4Comments  路  Source: jackc/pgx

Hello there. Is a complete sample available for replication? I want to send select queries to a database, write queries to a database.

Most helpful comment

@jackc thanks for your response. i have solved the issue with a simple wrapper which provides

Master() - master
Slave() - random slave
Random() - master slave random

with this i have much freedom

All 4 comments

Sorry, the only examples are the tests.

@jackc how to achieve this?

writes -> master
reads -> replicas

@k1ng440 pgx doesn't have built in support that and probably never can. It has no way of knowing if a given query is a write or not (even if it parsed the query string -- a select can cause a write).

You would need to establish different pools for the master and replicas and determine which pool to issue the command to at a higher level than pgx.

@jackc thanks for your response. i have solved the issue with a simple wrapper which provides

Master() - master
Slave() - random slave
Random() - master slave random

with this i have much freedom

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zamiell picture Zamiell  路  10Comments

nick-jones picture nick-jones  路  4Comments

jeromer picture jeromer  路  11Comments

skipcloud picture skipcloud  路  4Comments

kellabyte picture kellabyte  路  11Comments