SHOW extensions
In Vitess, SHOW has been extended with additional functionality.
SHOW Statements #
Vitess supports the following additional SHOW statements:
SHOW GLOBAL GTID_EXECUTED [FROM <keyspace>]-- retrieves the global gtid_executed status variable from each shard in the keyspace either selected or provided in the query.
Example Output for customer keyspace:
+----------+-------------------------------------------+-------+
| db_name | gtid_executed | shard |
+----------+-------------------------------------------+-------+
| customer | e9148eb0-a320-11eb-8026-98af65a6dc4a:1-43 | 80- |
| customer | e0f64aca-a320-11eb-9be4-98af65a6dc4a:1-43 | -80 |
+----------+-------------------------------------------+-------+
SHOW KEYSPACES-- A list of keyspaces available.
Example Output:
+----------+
| Database |
+----------+
| commerce |
| customer |
+----------+
SHOW VITESS_METADATA VARIABLES [LIKE "<pattern>"]-- Lists the key/value pairs stored withSET @@vitess_metadata.<key>, optionally filtered by key with aLIKEpattern. See Vitess Metadata.
Example Output:
+-------------+--------+
| Key | Value |
+-------------+--------+
| app_version | v1.2.3 |
+-------------+--------+
SHOW VITESS_REPLICATION_STATUS [LIKE "<Keyspace/<Shard>"](Experimental; 12.0+) -- Shows the Replication (not VReplication) health for the Vitess deployment. It returns a row for eachREPLICAandRDONLYtablet in the topology -- with support for filtering by Keyspace/Shard using aLIKEclause -- providing relevant health and status information, including the current tablet throttler status.
Example Output:
+----------+-------+------------+------------------+--------------+--------------------+-------------------------------------------------------------------------+----------------+-----------------------------------------+
| Keyspace | Shard | TabletType | Alias | Hostname | ReplicationSource | ReplicationHealth | ReplicationLag | ThrottlerStatus |
+----------+-------+------------+------------------+--------------+--------------------+-------------------------------------------------------------------------+----------------+-----------------------------------------+
| commerce | 0 | REPLICA | zone1-0000000101 | 52030e360852 | 52030e360852:17100 | {"EventStreamRunning":"Yes","EventApplierRunning":"Yes","LastError":""} | 0 | {"state":"OK","load":0.00,"message":""} |
| commerce | 0 | RDONLY | zone1-0000000102 | 52030e360852 | 52030e360852:17100 | {"EventStreamRunning":"Yes","EventApplierRunning":"Yes","LastError":""} | 0 | {"state":"OK","load":0.00,"message":""} |
+----------+-------+------------+------------------+--------------+--------------------+-------------------------------------------------------------------------+----------------+-----------------------------------------+
SHOW VITESS_SHARDS-- A list of shards that are available.
Example Output:
+--------------+
| Shards |
+--------------+
| commerce/0 |
| customer/-80 |
| customer/80- |
+--------------+
SHOW VITESS_TABLETS-- Information about the current Vitess tablets such as the keyspace, key ranges, tablet type, hostname, and status.
Example Output:
+-------+----------+-------+------------+---------+------------------+------------+----------------------+
| Cell | Keyspace | Shard | TabletType | State | Alias | Hostname | PrimaryTermStartTime |
+-------+----------+-------+------------+---------+------------------+------------+----------------------+
| zone1 | commerce | 0 | PRIMARY | SERVING | zone1-0000000100 | <redacted> | 2021-04-22T04:10:29Z |
| zone1 | commerce | 0 | REPLICA | SERVING | zone1-0000000101 | <redacted> | |
| zone1 | commerce | 0 | RDONLY | SERVING | zone1-0000000102 | <redacted> | |
| zone1 | customer | -80 | PRIMARY | SERVING | zone1-0000000300 | <redacted> | 2021-04-22T04:12:23Z |
| zone1 | customer | -80 | REPLICA | SERVING | zone1-0000000301 | <redacted> | |
| zone1 | customer | -80 | RDONLY | SERVING | zone1-0000000302 | <redacted> | |
| zone1 | customer | 80- | PRIMARY | SERVING | zone1-0000000400 | <redacted> | 2021-04-22T04:12:23Z |
| zone1 | customer | 80- | REPLICA | SERVING | zone1-0000000401 | <redacted> | |
| zone1 | customer | 80- | RDONLY | SERVING | zone1-0000000402 | <redacted> | |
+-------+----------+-------+------------+---------+------------------+------------+----------------------+
SHOW VSCHEMA KEYSPACES-- Information about Vschema information for all the keyspaces including the foreign key mode, whether the keyspace is sharded, and if there is an error in the VSchema for the keyspace.
Example Output:
+----------+---------+-------------+---------+
| Keyspace | Sharded | Foreign Key | Comment |
+----------+---------+-------------+---------+
| ks | true | managed | |
| uks | false | managed | |
+----------+---------+-------------+---------+
SHOW VSCHEMA TABLES-- A list of tables available in the current keyspace's vschema.
Example Output for customer keyspace:
+----------+
| Tables |
+----------+
| corder |
| customer |
| dual |
+----------+
SHOW VSCHEMA VINDEXES-- Information about the current keyspace's vindexes such as the keyspace, name, type, params, and owner. Optionally supports an "ON" clause with a table name.
Example Output:
+----------+------+------+--------+-------+
| Keyspace | Name | Type | Params | Owner |
+----------+------+------+--------+-------+
| customer | hash | hash | | |
+----------+------+------+--------+-------+
SHOW VITESS_THROTTLER STATUS-- shows status for all tablet throttlers in current keyspace
Example Output:
+-------+---------+-----------+
| shard | enabled | threshold |
+-------+---------+-----------+
| -80 | 1 | 1.5 |
| 80- | 1 | 1.5 |
+-------+---------+-----------+
Vitess Metadata #
Vitess metadata is a key/value store in the global topology server. Applications and tools can read and write it through vtgate to share small pieces of state, such as the version of an application or the progress of a workflow. Every change is a write to the global topology server, so it is not meant for large values or frequent updates.
To store a value, use SET with the vitess_metadata scope:
set @@vitess_metadata.app_version = 'v1.2.3';
- Only the users listed in the vtgate
--vschema-ddl-authorized-usersflag can set or delete keys. Other users get anot authorized to perform vitess metadata operationserror.SHOW VITESS_METADATA VARIABLEShas no such restriction. - Quote the value: a number,
NULLor an expression is rejected. - Vitess converts the key and a quoted value to lowercase before it stores them.
- Setting a key to an empty string deletes it. Deleting a key that does not exist returns an error.
To read the stored values, use SHOW VITESS_METADATA VARIABLES. _ and % are wildcards in a LIKE pattern, so escape them to match them literally. The match is case-sensitive, so use a lowercase pattern:
show vitess_metadata variables like 'app\_%';
The rows are not sorted. If no keys are stored, the statement returns a node doesn't exist error instead of an empty result.