Before a database server can be chosen, a server group must be chosen. The following values are taken into account:
server group name: If a server group name is specified directly, it is used.
shard table: If a shard table is given, the global group for the shard mapping governing the given shard table is used.
shard table + shard key: If a shard key is given the shard mapping is used to determine which server group handles data for the shard key.
The server group name can be accessed by
Once a server group is chosen, an individual database server is chosen based on the read-only state of the connection. A read-only server is chosen if one is available. Otherwise a read-write server is chosen. The server weight is not currently taken into account.
None of these values can be changed while a transaction is in progress.