SHOW STATS_LOCKED

SHOW STATS_LOCKED shows the tables whose statistics are locked.

Currently, the SHOW STATS_LOCKED statement returns the following columns:

Column nameDescription
Db_nameThe database name
Table_nameThe table name
Partition_nameThe partition name
StatusThe statistics status, such as locked

Synopsis

ShowStatsLockedStmt

SHOW STATS_LOCKED - 图1

ShowLikeOrWhereOpt

SHOW STATS_LOCKED - 图2

  1. ShowStatsLockedStmt ::= 'SHOW' 'STATS_LOCKED' ShowLikeOrWhereOpt
  2. ShowLikeOrWhereOpt ::= 'LIKE' SimpleExpr | 'WHERE' Expression

Examples

Create table t, and insert data into it. When the statistics of table t are not locked, the ANALYZE statement can be successfully executed.

  1. mysql> CREATE TABLE t(a INT, b INT);
  2. Query OK, 0 rows affected (0.03 sec)
  3. mysql> INSERT INTO t VALUES (1,2), (3,4), (5,6), (7,8);
  4. Query OK, 4 rows affected (0.00 sec)
  5. Records: 4 Duplicates: 0 Warnings: 0
  6. mysql> ANALYZE TABLE t;
  7. Query OK, 0 rows affected, 1 warning (0.02 sec)
  8. mysql> SHOW WARNINGS;
  9. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  10. | Level | Code | Message |
  11. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  12. | Note | 1105 | Analyze use auto adjusted sample rate 1.000000 for table test.t, reason to use this rate is "Row count in stats_meta is much smaller compared with the row count got by PD, use min(1, 15000/4) as the sample-rate=1" |
  13. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. 1 row in set (0.00 sec)

Lock the statistics of table t and execute SHOW STATS_LOCKED. The output shows that the statistics of table t have been locked.

  1. mysql> LOCK STATS t;
  2. Query OK, 0 rows affected (0.00 sec)
  3. mysql> SHOW STATS_LOCKED;
  4. +---------+------------+----------------+--------+
  5. | Db_name | Table_name | Partition_name | Status |
  6. +---------+------------+----------------+--------+
  7. | test | t | | locked |
  8. +---------+------------+----------------+--------+
  9. 1 row in set (0.01 sec)

MySQL compatibility

This statement is a TiDB extension to MySQL syntax.

See also