title | summary |
---|---|
UNLOCK STATS |
TiDB 数据库中 UNLOCK STATS 的使用概况。 |
UNLOCK STATS
语句用于解锁统计信息被锁定的表。
警告:
锁定统计信息目前为实验特性,不建议在生产环境中使用。
UnlockStatsStmt ::=
'UNLOCK' 'STATS' (TableNameList) | (TableName 'PARTITION' PartitionNameList)
TableNameList ::=
TableName (',' TableName)*
TableName ::=
Identifier ( '.' Identifier )?
PartitionNameList ::=
Identifier ( ',' 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)
该语句是 TiDB 对 MySQL 语法的扩展。