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

TableNameList

TableName

PartitionNameList

1. UnlockStatsStmt ::=
2. 'UNLOCK' 'STATS' (TableNameList | TableName 'PARTITION' PartitionNameList)
4. TableNameList ::=
5. TableName (',' TableName)*
7. TableName ::=
8. Identifier ( '.' Identifier )?
10. PartitionNameList ::=
11. Identifier ( ',' Identifier )*
示例
参考 LOCK STATS 语句的示例来创建表 t,并锁定表 t 的统计信息。
解锁表 t 的统计信息,成功执行 ANALYZE 语句。
1. mysql> UNLOCK STATS t;
2. Query OK, 0 rows affected (0.01 sec)
4. mysql> ANALYZE TABLE t;
5. Query OK, 0 rows affected, 1 warning (0.03 sec)
7. mysql> SHOW WARNINGS;
8. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+
9. | Level | Code | Message |
10. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+
11. | 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" |
12. +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------+
13. 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)
4. mysql> ANALYZE TABLE t PARTITION p1;
5. Query OK, 0 rows affected, 1 warning (0.01 sec)
7. mysql> SHOW WARNINGS;
8. +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9. | Level | Code | Message |
10. +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
11. | 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" |
12. +-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
13. 1 row in set (0.00 sec)
MySQL 兼容性
该语句是 TiDB 对 MySQL 语法的扩展。
