Hello there. Is a complete sample available for replication? I want to send select queries to a database, write queries to a database.
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
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