postgresml/pgcat

Question: How sharding is working?

olivierACRI opened this issue · 0 comments

Hi,
I am having +10 applications connecting to a postgres server to different databases (one per application). I was thinking that I can use Sharding to connect to a single pgCat config shard (to avoid creating a huge config for each application which will be very similar) and then based on the shard, connecting to the right database on the server (using the database field in the shard config).
I was thinking about this kind of configuration but... I am not understanding how the client will connect to the shard and database, using a nodejs library https://node-postgres.com/apis/client I am not seeing any shard related field.

[pools.sharded.shards.0]
servers = [
    [ "pgmain", 5432, "primary" ],
    [ "pgsecondary", 5432, "replica" ],
]
database = "db1"
[pools.sharded.shards.1]
servers = [
    [ "pgmain", 5432, "primary" ],
    [ "pgsecondary", 5432, "replica" ],
]
database = "db2"
...

I am confused by the fact that the pool_name is mentioned in the comment of the config as the name of the database and then the shards are having also a reference to a database name. My understanding was that we can connect all application using the same pool and then based on database they try to use they are routed to the right shard.

Anyone already implemented sharding and pgCat like that?