UNLOCK STATS

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

语法图

UnlockStatsStmt

UNLOCK STATS - 图1

TableNameList

UNLOCK STATS - 图2

TableName

UNLOCK STATS - 图3

PartitionNameList

UNLOCK STATS - 图4

  1. UnlockStatsStmt ::=
  2. 'UNLOCK' 'STATS' (TableNameList | TableName 'PARTITION' PartitionNameList)
  3. TableNameList ::=
  4. TableName (',' TableName)*
  5. TableName ::=
  6. Identifier ( '.' Identifier )?
  7. PartitionNameList ::=
  8. Identifier ( ',' Identifier )*

示例

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

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

  1. mysql> UNLOCK STATS t;
  2. Query OK, 0 rows affected (0.01 sec)
  3. mysql> ANALYZE TABLE t;
  4. Query OK, 0 rows affected, 1 warning (0.03 sec)
  5. mysql> SHOW WARNINGS;
  6. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+
  7. | Level | Code | Message |
  8. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+
  9. | 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" |
  10. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+
  11. 1 row in set (0.00 sec)

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

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

  1. mysql> UNLOCK STATS t PARTITION p1;
  2. Query OK, 0 rows affected (0.00 sec)
  3. mysql> ANALYZE TABLE t PARTITION p1;
  4. Query OK, 0 rows affected, 1 warning (0.01 sec)
  5. mysql> SHOW WARNINGS;
  6. +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  7. | Level | Code | Message |
  8. +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  9. | 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" |
  10. +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  11. 1 row in set (0.00 sec)

MySQL 兼容性

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

另请参阅