文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 28 个 INFORMATION_SCHEMA 表 / 28.4 INFORMATION_SCHEMA InnoDB 表 / 28.4.19 INFORMATION_SCHEMA INNODB_FT_INDEX_TABLE 表
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 73%

28.4.19 INFORMATION_SCHEMA INNODB_FT_INDEX_TABLE 表28.4.19 The INFORMATION_SCHEMA INNODB_FT_INDEX_TABLE Table

INNODB_FT_INDEX_TABLE 表提供有关用于处理 InnoDB 表 FULLTEXT 索引全文搜索的倒排索引的信息。The INNODB_FT_INDEX_TABLE table provides information about the inverted index used to process text searches against the FULLTEXT index of an InnoDB table.

此表最初为空。在查询它之前,将 innodb_ft_aux_table 系统变量的值设置为包含 FULLTEXT 索引的表的名称(包括数据库名称)(例如,test/articles)。This table is empty initially. Before querying it, set the value of the innodb_ft_aux_table system variable to the name (including the database name) of the table that contains the FULLTEXT index (for example, test/articles).

有关相关的使用信息和示例,请参见 第 17.15.4 节,“InnoDB INFORMATION_SCHEMA FULLTEXT 索引表”。For related usage information and examples, see Section 17.15.4, “InnoDB INFORMATION_SCHEMA FULLTEXT Index Tables”.

INNODB_FT_INDEX_TABLE 表具有以下列:The INNODB_FT_INDEX_TABLE table has these columns:

  • WORD

    从属于 FULLTEXT 的列文本中提取的单词。A word extracted from the text of the columns that are part of a FULLTEXT.

  • FIRST_DOC_ID

    该单词在 FULLTEXT 索引中出现的第一个文档 ID。The first document ID in which this word appears in the FULLTEXT index.

  • LAST_DOC_ID

    该单词在 FULLTEXT 索引中出现的最后一个文档 ID。The last document ID in which this word appears in the FULLTEXT index.

  • DOC_COUNT

    该单词在 FULLTEXT 索引中出现的行数。相同的单词可以在缓存表中出现多次,每次对应不同的 DOC_ID 和 POSITION 值组合。The number of rows in which this word appears in the FULLTEXT index. The same word can occur several times within the cache table, once for each combination of DOC_ID and POSITION values.

  • DOC_ID

    包含该单词的行的文档 ID。此值可能反映您为基础表定义的 ID 列的值,或者当表中没有合适的列时,它可以是由 InnoDB 生成的序列值。The document ID of the row containing the word. This value might reflect the value of an ID column that you defined for the underlying table, or it can be a sequence value generated by InnoDB when the table contains no suitable column.

  • POSITION

    在由 DOC_ID 值标识的相关文档中,该单词特定实例的位置。The position of this particular instance of the word within the relevant document identified by the DOC_ID value.

注意事项Notes

  • 这个表最初是空的。在查询它之前,将 innodb_ft_aux_table 系统变量的值设置为包含 FULLTEXT 索引的表名(包括数据库名)(例如,test/articles)。以下示例演示了如何使用 innodb_ft_aux_table 系统变量来显示指定表的 FULLTEXT 索引信息。在 INNODB_FT_INDEX_TABLE 中显示新插入行的信息之前,FULLTEXT 索引缓存必须刷新到磁盘。这可以通过对被索引的表运行 OPTIMIZE TABLE 操作并启用 innodb_optimize_fulltext_only 系统变量来实现。(示例在最后又将该变量禁用,因为它仅打算临时启用。)This table is empty initially. Before querying it, set the value of the innodb_ft_aux_table system variable to the name (including the database name) of the table that contains the FULLTEXT index (for example, test/articles). The following example demonstrates how to use the innodb_ft_aux_table system variable to show information about a FULLTEXT index for a specified table. Before information for newly inserted rows appears in INNODB_FT_INDEX_TABLE, the FULLTEXT index cache must be flushed to disk. This is accomplished by running an OPTIMIZE TABLE operation on the indexed table with the innodb_optimize_fulltext_only system variable enabled. (The example disables that variable again at the end because it is intended to be enabled only temporarily.)

    mysql> USE test;
    
    mysql> CREATE TABLE articles (
             id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
             title VARCHAR(200),
             body TEXT,
             FULLTEXT (title,body)
           ) ENGINE=InnoDB;
    
    mysql> INSERT INTO articles (title,body) VALUES
           ('MySQL Tutorial','DBMS stands for DataBase ...'),
           ('How To Use MySQL Well','After you went through a ...'),
           ('Optimizing MySQL','In this tutorial we show ...'),
           ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
           ('MySQL vs. YourSQL','In the following database comparison ...'),
           ('MySQL Security','When configured properly, MySQL ...');
    
    mysql> SET GLOBAL innodb_optimize_fulltext_only=ON;
    
    mysql> OPTIMIZE TABLE articles;
    +---------------+----------+----------+----------+
    | Table         | Op       | Msg_type | Msg_text |
    +---------------+----------+----------+----------+
    | test.articles | optimize | status   | OK       |
    +---------------+----------+----------+----------+
    
    mysql> SET GLOBAL innodb_ft_aux_table = 'test/articles';
    
    mysql> SELECT WORD, DOC_COUNT, DOC_ID, POSITION
           FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE LIMIT 5;
    +------------+-----------+--------+----------+
    | WORD       | DOC_COUNT | DOC_ID | POSITION |
    +------------+-----------+--------+----------+
    | 1001       |         1 |      4 |        0 |
    | after      |         1 |      2 |       22 |
    | comparison |         1 |      5 |       44 |
    | configured |         1 |      6 |       20 |
    | database   |         2 |      1 |       31 |
    +------------+-----------+--------+----------+
    
    mysql> SET GLOBAL innodb_optimize_fulltext_only=OFF;
    
  • 你必须拥有 PROCESS 权限才能查询此表。You must have the PROCESS privilege to query this table.

  • 使用 INFORMATION_SCHEMA COLUMNS 表或 SHOW COLUMNS 语句查看关于此表列的更多信息,包括数据类型和默认值。Use the INFORMATION_SCHEMA COLUMNS table or the SHOW COLUMNS statement to view additional information about the columns of this table, including data types and default values.

  • 有关 InnoDB FULLTEXT 搜索的更多信息,请参见 第 17.6.2.4 节,“InnoDB 全文索引”,以及 第 14.9 节,“全文搜索函数”。For more information about InnoDB FULLTEXT search, see Section 17.6.2.4, “InnoDB Full-Text Indexes”, and Section 14.9, “Full-Text Search Functions”.