SHOW EXPERIMENTAL_RANGES

On this page Carat arrow pointing down
Warning:
CockroachDB v2.0 is no longer supported as of October 4, 2019. For more details, refer to the Release Support Policy.

The SHOW EXPERIMENTAL_RANGES statement shows information about the ranges that make up a specific table's data, including:

  • The start and end keys for the range(s)
  • The range ID(s)
  • Which nodes contain the range replicas
  • Which node contains the range that is the leaseholder

This information is useful for verifying that:

Warning:

This is an experimental feature. The interface and output are subject to change.

Synopsis

SHOW EXPERIMENTAL_RANGES FROM TABLE table_name INDEX table_name_with_index

Required Privileges

The user must have the SELECT privilege on the target table.

Parameters

Parameter Description
table_name The name of the table you want range information about.
table_name_with_index The name of the index you want range information about.

Examples

The examples in this section operate on a hypothetical "user credit information" table filled with placeholder data, running on a 5-node cluster.

icon/buttons/copy
> CREATE TABLE credit_users (
       id INT PRIMARY KEY,
       area_code INTEGER NOT NULL,
       name STRING UNIQUE NOT NULL,
       address STRING NOT NULL,
       zip_code INTEGER NOT NULL,
       credit_score INTEGER NOT NULL
);

We added a secondary index to the table on the area_code column:

icon/buttons/copy
> CREATE INDEX areaCode on credit_users(area_code);

Next, we ran a couple of SPLIT ATs on the table and the index:

icon/buttons/copy
> ALTER TABLE credit_users SPLIT AT VALUES (5), (10), (15);
icon/buttons/copy
> ALTER INDEX credit_users@areaCode SPLIT AT VALUES (400), (600), (999);
Note:

In the example output below, a NULL in the Start Key column means "beginning of table".
A NULL in the End Key column means "end of table".

Show Ranges for a Table (Primary Index)

icon/buttons/copy
> SHOW EXPERIMENTAL_RANGES FROM TABLE credit_users;
+-----------+---------+----------+----------+--------------+
| Start Key | End Key | Range ID | Replicas | Lease Holder |
+-----------+---------+----------+----------+--------------+
| NULL      | /5      |      158 | {2,3,5}  |            5 |
| /5        | /10     |      159 | {3,4,5}  |            5 |
| /10       | /15     |      160 | {2,4,5}  |            5 |
| /15       | NULL    |      161 | {2,3,5}  |            5 |
+-----------+---------+----------+----------+--------------+
(4 rows)

Show Ranges for an Index

icon/buttons/copy
> SHOW EXPERIMENTAL_RANGES FROM INDEX credit_users@areaCode;
+-----------+---------+----------+-----------+--------------+
| Start Key | End Key | Range ID | Replicas  | Lease Holder |
+-----------+---------+----------+-----------+--------------+
| NULL      | /400    |      135 | {2,4,5}   |            2 |
| /400      | /600    |      136 | {2,4,5}   |            4 |
| /600      | /999    |      137 | {1,3,4,5} |            3 |
| /999      | NULL    |       72 | {2,3,4,5} |            4 |
+-----------+---------+----------+-----------+--------------+
(4 rows)

See Also


Yes No
On this page

Yes No