YugabyteDB Tips
  • Home
  • About
  • Featured Videos

View Metadata for YSQL/YCQL/System Tablets on a Server

YugabyteDB Tips > Meta-Data > View Metadata for YSQL/YCQL/System Tablets on a Server

View Metadata for YSQL/YCQL/System Tablets on a Server

Jim KnicelyAugust 3, 2024

Introduced in YugabyteDB 2024.1.0, the YSQL yb_local_tablets view allows you to easily fetch the metadata for YSQL, YCQL, and system tablets of a node.

This view returns the same information that is available on <yb-tserver-ip>:9000/tablets.

YSQL Example:

				
					[root@cloud-server-0 ~]# ysqlsh -h 127.0.0.2 -c "CREATE TABLE ysql_table(id INT PRIMARY KEY, c1 TEXT) SPLIT INTO 6 TABLETS;"
CREATE TABLE

[root@cloud-server-0 ~]# ysqlsh -h 127.0.0.2 -c "SELECT * FROM yb_local_tablets WHERE table_name = 'ysql_table';"
            tablet_id             |             table_id             | table_type | namespace_name | ysql_schema_name | table_na
me | partition_key_start | partition_key_end
----------------------------------+----------------------------------+------------+----------------+------------------+---------
---+---------------------+-------------------
 7cf1af9f0c4241f2916d8f00354b8e55 | 000033c3000030008000000000004100 | YSQL       | yugabyte       | public           | ysql_tab
le | \xd555              |
 be87e101f1544b019becb2cb9e4b82b1 | 000033c3000030008000000000004100 | YSQL       | yugabyte       | public           | ysql_tab
le |                     | \x2aaa
 33c41a590cbd4fe2aac14634b3fc023d | 000033c3000030008000000000004100 | YSQL       | yugabyte       | public           | ysql_tab
le | \xaaaa              | \xd555
 021dbf1d067247fd9a6298b8b5c829fb | 000033c3000030008000000000004100 | YSQL       | yugabyte       | public           | ysql_tab
le | \x5555              | \x8000
 61e4727eb01d46e9a469a362e0da802c | 000033c3000030008000000000004100 | YSQL       | yugabyte       | public           | ysql_tab
le | \x8000              | \xaaaa
 64f261c4fd024e1394b43c3bfb66cb15 | 000033c3000030008000000000004100 | YSQL       | yugabyte       | public           | ysql_tab
le | \x2aaa              | \x5555
(6 rows)
				
			

YCQL Example:

				
					[root@cloud-server-0 ~]# ycqlsh 127.0.0.2 -e "CREATE KEYSPACE ks; CREATE TABLE ks.ycql_table(id INT PRIMARY KEY, c1 TEXT) WITH TABLETS = 6;"

[root@cloud-server-0 ~]# ysqlsh -h 127.0.0.2 -c "SELECT * FROM yb_local_tablets WHERE table_name = 'ycql_table';"
            tablet_id             |             table_id             | table_type | namespace_name | ysql_schema_name | table_na
me | partition_key_start | partition_key_end
----------------------------------+----------------------------------+------------+----------------+------------------+---------
---+---------------------+-------------------
 63a21e9adcff4953a44d6dd570aedf73 | 8a598a5e8ab9471e8e6205cf8bc0809a | YCQL       | ks             |                  | ycql_tab
le | \xd555              |
 397309febb384e12a00543dd9b85cd3e | 8a598a5e8ab9471e8e6205cf8bc0809a | YCQL       | ks             |                  | ycql_tab
le | \x5555              | \x8000
 5911c8e4c10a4d13aaf9b32a663f92dd | 8a598a5e8ab9471e8e6205cf8bc0809a | YCQL       | ks             |                  | ycql_tab
le |                     | \x2aaa
 70485dcd828e4cbb8dae0739e308d2b2 | 8a598a5e8ab9471e8e6205cf8bc0809a | YCQL       | ks             |                  | ycql_tab
le | \x8000              | \xaaaa
 bcb196b137b64d4092a39d772d468cc3 | 8a598a5e8ab9471e8e6205cf8bc0809a | YCQL       | ks             |                  | ycql_tab
le | \xaaaa              | \xd555
 ee6c7085c7ba43e08eb1fd281cd6be9e | 8a598a5e8ab9471e8e6205cf8bc0809a | YCQL       | ks             |                  | ycql_tab
le | \x2aaa              | \x5555
(6 rows)
				
			

Note that in the YCQL example, even though the table is a YCQL table, we still query the YSQL yb_local_tablets view to obtain the tablet meta-data.

Have Fun!

While attending a work event in Boston, I had the chance to play table tennis in a new way!
Meta-Data, YCQL, ysql

Post navigation

Creating Indexes on ARRAY Columns in YSQL
Presplit a Materilized View into a Specific Number of Tablets



YugabyteDB Tips

Copyright 2025 - Knicely/Li