cdr list shardCollection

The cdr list shardCollection command displays the sharding definition for all database servers in a shard cluster.

Syntax


1  cdr list shardCollection definition_name?  %Connect Option(1)
Notes:
Element Description Restrictions
definition_name The name of the sharding definition that is used for distributing data across multiple database servers. Must be the name of an existing definition.

Usage

The cdr list shardCollection command displays the sharding definition for database servers in a shard cluster.

Return codes

A return code of 0 indicates that the command was successful.

If the command is not successful, one of the following error codes is returned: 99, 196, 229.

For information on these error codes, see Return Codes for the cdr Utility.

Example: Output for a sharding definition that uses consistent hash-based sharding

For this example, you have a sharding definition that is created by the following command:

cdr define shardCollection collection_1 db_1:john.customers   
   --type=delete --key=b --strategy=chash --partitions=3 --versionCol=column_3      
   g_shard_server_1 g_shard_server_2 g_shard_server_3 

The following example shows output when the cdr list shardCollection command is run on a database server in the shard cluster. Each shard server has three hashing partitions.

Figure 1: Output when the cdr list shardCollection is run on a shard server that uses consistent hash-based sharding.
Shard Collection:shrdb Version:0 type:consistent hash key:b
Version Column:column_3
Table:db_1:john.customers
g_shard_server_1     (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 4019 and 5469)
                      or (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 5719 and 6123)  
                      or (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 2113 and 2652)
g_shard_server_2     (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 6124 and 7415)
                      or (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 5470 and 5718)  
                      or (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 7416 and 7873)
g_shard_server_3     (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 2653 and 3950)
                      or mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) >= 7874 
                      or mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) < 2113   
                      or (mod(abs(ifx_checksum(b::LVARCHAR, 0)), 10000) between 3951 and 40

Example: Output for a sharding definition that uses hash-based sharding

For this example, you have a sharding definition that is created by the following command:
cdr define shardCollection collection_1 database_1:john.customers_1
   --type=delete --key=col2 --strategy=hash --versionCol=column_3
   g_shard_server_A
   g_shard_server_B
   g_shard_server_C
   g_shard_server_D

The following example shows output when the cdr list shardCollection command is run on a database server in the shard cluster.

Figure 2: Output when the cdr list shardCollection is run on a shard server that uses hash-based sharding.
Shard Collection:collection_1 Version:0 type:hash key:col2
Version Column:column_3
Table:database_1:john.customers_1
g_shard_server_A      mod(ifx_checksum(col2::LVARCHAR, 0), 4)  = 0
g_shard_server_B      mod(ifx_checksum(col2::LVARCHAR, 0), 4)  in (1, -1)
g_shard_server_C      mod(ifx_checksum(col2::LVARCHAR, 0), 4)  in (2, -2)
g_shard_server_D      mod(ifx_checksum(col2::LVARCHAR, 0), 4)  in (3, -3)

Example: Output for a sharding definition that uses an expression

For this example, you have a sharding definition that is created by the following command:
cdr define shardCollection collection_2 database_2:joe.customers_2
   -t delete -k state -s expression -v column_3
   g_shard_server_F "IN ('AL','MS','GA')"
   g_shard_server_G "IN ('TX','OK','NM')"
   g_shard_server_H "IN ('NY','NJ')"
   g_shard_server_I  remainder

The following example shows output when the cdr list shardCollection command is run on a database server in the shard cluster.

Figure 3: Output when the cdr list shardCollection is run on a shard server that uses expression-based sharding.
Shard Collection:collection_2 Version:0 type:expression key:state
Version Column:column_3
Table:database_2:joe.customers_2
g_shard_server_F      state IN ('AL','MS','GA')
g_shard_server_G      state IN ('TX','OK','NM')
g_shard_server_H      state IN ('NY','NJ')
g_shard_server_I      not ( (state IN ('AL','MS','GA') ) or  (state
IN ('TX','OK','NM') ) or  (state IN ('NY','NJ') ))

Example: Output for a sharding definition that was modified

For this example, you have a sharding definition that is created by the following command:
cdr define shardCollection collection_3 database_3:tony.customers_3
   -t keep -k bson_value_lvarchar(data,'year') -s expression -v column_3
   g_shard_server_J "BETWEEN 1970 and 1979"
   g_shard_server_K "BETWEEN 1980 and 1989"
   g_shard_server_L "BETWEEN 1990 and 1999"
   g_shard_server_M  remainder
The sharding definition is then modified by the following command:
cdr change shardCollection collection_3 -a
   g_shard_server_N "BETWEEN 2000 and 2009"
The sharding definition is then modified a second time:
cdr change shardCollection collection_3 -d g_shard_server_J

The following example shows output when the cdr list shardCollection command is run on a database server in the shard cluster. The Version value increments with each cdr change shardCollection command that successfully runs on collection_3.

Figure 4: Output when the cdr list shardCollection is run on a shard server that has a modified sharding definition.
Shard Collection:collection_3 Version:2 type:expression
key:bson_value_lvarchar(data,'year') Version Column:column_3
Table:database_3:tony.customers_3
g_shard_server_K      bson_value_lvarchar(data,'year') BETWEEN 1980 and 1989
g_shard_server_L      bson_value_lvarchar(data,'year') BETWEEN 1990 and 1999
g_shard_server_N      bson_value_lvarchar(data,'year') BETWEEN 2000 and 2009
g_shard_server_M      not((bson_value_lvarchar(data,'year') BETWEEN 1980 and 1989)
or (bson_value_lvarchar(data,'year') BETWEEN 1990 and 1999) or (bson_value_lvarchar
(data,'year') BETWEEN 2000 and 2009))