INNODB_FT_INDEX_CACHE 详解

Posted by 道行尚浅 on January 24, 2021

系统表介绍

INNODB_FT_INDEX_CACHE 表记录了全文索引 新插入行的token信息。

列名 含义
WORD
FIRST_DOC_ID 全文索引中第一个文档的编号
LAST_DOC_ID 全文索引中最后一个文档的编号
DOC_COUNT 文档数量
DOC_ID 文档ID
POSITION 在相关文档中的位置

实例


mysql> use dao ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> CREATE TABLE articles (
    ->          id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    ->          title VARCHAR(200),
    ->          body TEXT,
    ->          FULLTEXT (title,body)
    ->        ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.16 sec)

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 ...');
Query OK, 6 rows affected (0.02 sec)
Records: 6  Duplicates: 0  Warnings: 0

mysql>  SET GLOBAL innodb_ft_aux_table = 'dao/articles';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT WORD, DOC_COUNT, DOC_ID, POSITION
    ->        FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE;
+------------+-----------+--------+----------+
| WORD       | DOC_COUNT | DOC_ID | POSITION |
+------------+-----------+--------+----------+
| 1001       |         1 |      5 |        0 |
| After      |         1 |      3 |       22 |
| DBMS       |         1 |      2 |       15 |
| DataBase   |         1 |      2 |       31 |
| MySQL      |         6 |      2 |        0 |
| MySQL      |         6 |      3 |       11 |
| MySQL      |         6 |      4 |       11 |
| MySQL      |         6 |      5 |        5 |
| MySQL      |         6 |      6 |        0 |
| MySQL      |         6 |      7 |        0 |
| MySQL      |         6 |      7 |       41 |
| Never      |         1 |      5 |       21 |
| Optimizing |         1 |      4 |        0 |
| Security   |         1 |      7 |        6 |
| Tricks     |         1 |      5 |       11 |
| Tutorial   |         1 |      2 |        6 |
| Use        |         1 |      3 |        7 |
| Well       |         1 |      3 |       17 |
| YourSQL    |         1 |      6 |       10 |
| comparison |         1 |      6 |       44 |
| configured |         1 |      7 |       20 |
| database   |         1 |      6 |       35 |
| following  |         1 |      6 |       25 |
| mysqld     |         1 |      5 |       31 |
| properly   |         1 |      7 |       31 |
| root       |         1 |      5 |       41 |
| run        |         1 |      5 |       27 |
| show       |         1 |      4 |       37 |
| stands     |         1 |      2 |       20 |
| through    |         1 |      3 |       37 |
| tutorial   |         1 |      4 |       25 |
| went       |         1 |      3 |       32 |
| you        |         1 |      3 |       28 |
+------------+-----------+--------+----------+
33 rows in set (0.00 sec)