Display the Shards (Tablets) for a YCQL Table

Yugabyte DB automatically splits tables into multiple shards, called tablets, using either hash or range-based strategy. Sharding is a process of breaking up large tables into smaller shards that are spread across multiple servers. A shard is essentially a horizontal data partition that contains a subset of the total data set.

You can display the shards (tablets) in YCQL by querying the SYSTEM.PARTITIONS table.

				
					SELECT id, replica_addresses FROM system.partitions WHERE keyspace_name = 'keyspace name' and table_name = 'table name';
				
			

Example:

				
					cassandra@ycqlsh> CREATE KEYSPACE test;

cassandra@ycqlsh> USE test;

cassandra@ycqlsh:test> CREATE TABLE test (c1 INT, c2 VARCHAR, c3 VARCHAR, PRIMARY KEY((c1), c2));

cassandra@ycqlsh:test> SELECT id, replica_addresses FROM system.partitions WHERE keyspace_name = 'test' and table_name = 'test';

 id                                   | replica_addresses
--------------------------------------+----------------------------------------------------------------------------------------
 9a75898f-a2fe-68af-a54f-250b46d1357f | {'172.161.25.249': 'FOLLOWER', '172.161.46.42': 'FOLLOWER', '172.161.55.44': 'LEADER'}
 1aca3973-32e6-38af-da48-7517b27adcc2 | {'172.161.25.249': 'FOLLOWER', '172.161.46.42': 'LEADER', '172.161.55.44': 'FOLLOWER'}
 2bc3001a-1a65-1daa-7845-264fd18a3005 | {'172.161.25.249': 'LEADER', '172.161.46.42': 'FOLLOWER', '172.161.55.44': 'FOLLOWER'}

(3 rows)
				
			

In the example above the TEST table has three shards (tablets).

Have Fun!