UNLOCK STATS

UNLOCK STATS is used to unlock the statistics of a table or tables.

Synopsis

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 )*

Examples

Refer to the examples in LOCK STATS and create a table t and lock its statistics.

Unlock the statistics of table t, and ANALYZE can be successfully executed.

  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)

Refer to examples in LOCK STATS and create a table t and lock the statistics of its partition p1.

Unlock the statistics of partition p1, and ANALYZE can be successfully executed.

  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 compatibility

This statement is a TiDB extension to MySQL syntax.

See also