【发布时间】:2019-04-16 10:45:36
【问题描述】:
我正在尝试使用全文分数获得全文搜索的 10 个最佳匹配项。
以下查询在我的 10M 行 MyISAM 表上完美运行:
SELECT
index,
MATCH(villes) AGAINST('montreuil') as score
FROM
(
SELECT index, villes
FROM table
WHERE MATCH(villes) AGAINST('montreuil' IN BOOLEAN MODE)
) t
但是,当我在尝试检索订单分数时遇到错误时:
SELECT index
FROM (
*** PREVIOUS QUERY ***
) t2
ORDER BY t2.score
错误是:4 秒后 mysql 工作台中的“与 mysql 服务器的连接丢失”。
到目前为止我已经尝试过:
- 使用 phpmyadmin => 相同的错误
- 删除“order by”=>同样的错误
- 扩展mysql缓冲内存=>同样的错误
- 将子查询结果的数量限制为 10(使用“limit 10”)=> 奇怪的错误“找不到全文索引”
mysql 日志我不清楚:
10:10:58 UTC - mysqld got exception 0xc00000fd ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.
key_buffer_size=67108864
read_buffer_size=8388608
max_used_connections=3
max_threads=151
thread_count=2
connection_count=2
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 2541349 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x21ee0a9b580
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
2019-04-16T10:11:12.359438Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
编辑
显示创建表:
'CREATE TABLE `table` (
`index` int(11) NOT NULL,
`villes` text,
PRIMARY KEY (`index`),
FULLTEXT KEY `villes` (`villes`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8'
解释:
type: fulltext
possible keys: villes
key: villes
ref: const
rows: 1
filtered: 100.00
extra: using where, using filesort
【问题讨论】:
-
能否分享一下表结构(
SHOW CREATE TABLE <table>)和查询计划(EXPLAIN <query>) -
检查您的数据中是否有您尝试获取的单引号。就像我们一样,就是这样。
-
this 很可能是 MySQL 杀死查询线程的原因,尝试升级到至少 MySQL 8.0.13+,它允许
TEXT作为内部临时内存表而不是磁盘临时表跨度> -
很好的建议@RaymondNijland 但我刚刚切换到 mysql 8 并且 mysql 仍然失去连接。真的可能是那个问题。
-
附加信息请求。在 pastebin.com 上发布并分享链接。您的 MySQL 主机服务器的 RAM 大小 A) 完整(未编辑)my.cnf 或 my.ini 文本结果: B) SHOW GLOBAL STATUS;至少 24 小时正常运行时间后 C) 显示全局变量; D) 显示完整的处理程序; E) 完整的 MySQLTuner 报告和可选的非常有用的信息,如果可用,包括 - htop OR top OR mytop 用于大多数活动应用程序,ulimit -a 用于 linux/unix 限制列表,iostat -xm 5 3 用于按设备和核心/cpu 的 IOPS计数,用于服务器调优分析。