SHOW PLACEMENT FOR

SHOW PLACEMENT FOR summarizes all placement options, and presents them in the canonical form for a specific table, database schema, or partition.

SHOW PLACEMENT FOR - 图1

Note

This feature is not available on TiDB Serverless clusters.

The statement returns a result set in which the Scheduling_State field indicates the current progress that the Placement Driver (PD) has made in scheduling the placement:

  • PENDING: The PD has not yet started scheduling the placement. This might indicate that that the placement rules are semantically correct, but cannot currently be satisfied by the cluster. For example, if FOLLOWERS=4 but there are only 3 TiKV stores that are candidates for followers.
  • INPROGRESS: The PD is currently scheduling the placement.
  • SCHEDULED: The PD has successfully scheduled the placement.

Synopsis

ShowStmt

SHOW PLACEMENT FOR - 图2

ShowPlacementTarget

SHOW PLACEMENT FOR - 图3

  1. ShowStmt ::=
  2. "SHOW" "PLACEMENT" "FOR" ShowPlacementTarget
  3. ShowPlacementTarget ::=
  4. DatabaseSym DBName
  5. | "TABLE" TableName
  6. | "TABLE" TableName "PARTITION" Identifier

Examples

  1. CREATE PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4;
  2. ALTER DATABASE test PLACEMENT POLICY=p1;
  3. CREATE TABLE t1 (a INT);
  4. SHOW PLACEMENT FOR DATABASE test;
  5. SHOW PLACEMENT FOR TABLE t1;
  6. SHOW CREATE TABLE t1\G
  7. CREATE TABLE t3 (a INT) PARTITION BY RANGE (a) (PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (20));
  8. SHOW PLACEMENT FOR TABLE t3 PARTITION p1\G
  1. Query OK, 0 rows affected (0.02 sec)
  2. Query OK, 0 rows affected (0.00 sec)
  3. Query OK, 0 rows affected (0.01 sec)
  4. +---------------+----------------------------------------------------------------------+------------------+
  5. | Target | Placement | Scheduling_State |
  6. +---------------+----------------------------------------------------------------------+------------------+
  7. | DATABASE test | PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4 | INPROGRESS |
  8. +---------------+----------------------------------------------------------------------+------------------+
  9. 1 row in set (0.00 sec)
  10. +---------------+-------------+------------------+
  11. | Target | Placement | Scheduling_State |
  12. +---------------+-------------+------------------+
  13. | TABLE test.t1 | FOLLOWERS=4 | INPROGRESS |
  14. +---------------+-------------+------------------+
  15. 1 row in set (0.00 sec)
  16. ***************************[ 1. row ]***************************
  17. Table | t1
  18. Create Table | CREATE TABLE `t1` (
  19. `a` int(11) DEFAULT NULL
  20. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![placement] PLACEMENT POLICY=`p1` */
  21. 1 row in set (0.00 sec)
  22. ***************************[ 1. row ]***************************
  23. Target | TABLE test.t3 PARTITION p1
  24. Placement | PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-west-1" FOLLOWERS=4
  25. Scheduling_State | PENDING
  26. 1 row in set (0.00 sec)

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.

See also