要求mysql以更快的速度索引全文

问题描述 投票:0回答:1

通过 mysql 全文搜索,我使用该方法禁用了停用词

ft_stopword_file = ""
ft_min_word_len = 1

然后我删除了全文索引并重新创建了它们。

现在真正的问题是,大约有 500K 行需要为全文建立索引。

当我使用查询搜索“java”时 -

select job_id from job_posts where match(description) 
against ('+"java"' in boolean mode) order by job_id desc limit 10;

它出现了-

10 rows in set (41.73 sec)

CPU 在 42 秒内保持在 15-25% 左右

当我搜索“with”时,查询 -

 select job_id from job_posts where match(description) 
 against ('+"with"' in boolean mode) order by job_id desc limit 10;

它出现了-

10 rows in set (3 min 22.04 sec)

CPU 再次处于 15-25% 的 3.3 分钟

为什么“java”比“with”只花费 20% 的时间,因为两者都是 4 个字母的单词?

我看到没有任何查询mysql正在闲置 <2% cpu which means it is indexing but at a very slow rate.

有什么方法可以要求或设置mysql使用~50%的cpu和磁盘以更高的速率建立索引?

为了进行实时查询,您可以搜索字符串这里

表的创建语句 -

CREATE TABLE `job_posts` (
  `job_id` bigint NOT NULL AUTO_INCREMENT,
  `title` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci,
  `state` bigint DEFAULT NULL,
  `country` bigint DEFAULT NULL,
  `email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `city` bigint DEFAULT NULL,
  `post_date` datetime DEFAULT CURRENT_TIMESTAMP,
  `msg_no` bigint DEFAULT NULL,
  `is_hotlist` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
  `cviews` bigint DEFAULT NULL,
  `em_id` bigint DEFAULT NULL,
  PRIMARY KEY (`job_id`),
  KEY `id_email` (`em_id`),
  FULLTEXT KEY `full_text` (`description`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
mysql full-text-search
1个回答
0
投票

with
位于默认的停用词列表中,不会被索引。因此,查找
against ('+"with"' in boolean mode)
需要更长的时间。

正如我在评论中已经提到的,设置

ft_stop_word_file=''
没有任何效果,因为此设置仅影响 MyISAM 表,但您的表是 InnoDB 表。

© www.soinside.com 2019 - 2024. All rights reserved.