GoLang API to access num shards per tablet

We are using client driver(sql package - database/sql - Go Packages)
To establish connection/session with postgres(yugabyte DB 2.8.3) and to execute SQL query


There is a variable ysql_num_shards_per_tserver configured with every TSERVER


What is the GoLang API in client driver to retrieve value of ysql_num_shards_per_tserver ?

There is no API. Why do you need this? Since you set it yourself on the configuration?

@dorian_yugabyte

We would like to determine hash ranges of each tablet based on:

tablets= ysql_num_shards_per_tserver * num_tservers
before running SELECT query

Example:
For 48 tablets,
first hash range is [0, 1395)
second hash range is [1395, 2730)

For 4 tablets,
Tablet 1 hash range [0,16384)
Tablet 2 hash range [16384, 32768)
Tablet 3 hash range [32768, 49152)
Tablet 4 hash range [49152, 65535]

You can ask the guy who deploys the YugabyteDB cluster in your case and just save that number in a configuration in your app since you can’t query it from the server.

@dorian_yugabyte

yes we did the same

1 Like