UNLOCK STATS

UNLOCK STATS 语句用于解锁统计信息被锁定的表。

语法图

UnlockStatsStmt
UNLOCKSTATSTableNameListTableNamePARTITIONPartitionNameList
TableNameList
TableName,
TableName
Identifier.Identifier
PartitionNameList
Identifier,

示例

参考 LOCK STATS 语句的示例来创建表 t,并锁定表 t 的统计信息。

解锁表 t 的统计信息,成功执行 ANALYZE 语句。

mysql> UNLOCK STATS t; Query OK, 0 rows affected (0.01 sec) mysql> ANALYZE TABLE t; Query OK, 0 rows affected, 1 warning (0.03 sec) mysql> SHOW WARNINGS; +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+ | Note | 1105 | Analyze use auto adjusted sample rate 1.000000 for table test.t, reason to use this rate is "use min(1, 110000/8) as the sample-rate=1" | +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)

参考 LOCK STATS 语句的示例来创建表 t,并锁定表 t 的分区 p1 的统计信息。

解锁分区 p1 的统计信息,成功执行 ANALYZE 语句。

mysql> UNLOCK STATS t PARTITION p1; Query OK, 0 rows affected (0.00 sec) mysql> ANALYZE TABLE t PARTITION p1; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> SHOW WARNINGS; +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Note | 1105 | Analyze use auto adjusted sample rate 1.000000 for table test.t's partition p1, reason to use this rate is "TiDB assumes that the table is empty, use sample-rate=1" | +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)

MySQL 兼容性

该语句是 TiDB 对 MySQL 语法的扩展。

另请参阅

文档内容是否有帮助?