0

Im trying to get the 10 best matches of a fulltext search using fulltext score.

Following query works perfectly on my 10M lines MyISAM table :

SELECT 

    index,
    MATCH(villes) AGAINST('montreuil') as score
FROM 
    (

        SELECT index, villes
        FROM table
        WHERE MATCH(villes) AGAINST('montreuil' IN BOOLEAN MODE) 

    ) t

However, when I get an error when trying to retrieve to order scores :

SELECT index 

FROM (

       *** PREVIOUS QUERY ***

) t2

ORDER BY t2.score

Error is : "Lost connection to mysql server" in mysql workbench after 4 seconds.

So far I've tried:

  • using phpmyadmin => same error
  • removing the "order by" => same error
  • extending the mysql buffer memory => same error
  • limiting the number of the subquery results to 10 (using "limit 10") => weird error "cannot find a fulltext index"

The mysql log is unclear to me :

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.

EDIT

SHOW CREATE TABLE :

'CREATE TABLE `table` (
  `index` int(11) NOT NULL,
  `villes` text,
  PRIMARY KEY (`index`),
  FULLTEXT KEY `villes` (`villes`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8'

EXPLAIN :

type: fulltext
possible keys: villes
key: villes
ref: const
rows: 1
filtered: 100.00
extra: using where, using filesort
6
  • Can you share the table structure (SHOW CREATE TABLE <table>) and the query plan (EXPLAIN <query>) Apr 16, 2019 at 10:49
  • Check if you have a single quote in your data which you are trying to fetch. Like let's, that's.
    – Kuldeep
    Apr 16, 2019 at 10:50
  • Most likely this is the reason why MySQL kills the query thread, try upgrading to atleast MySQL 8.0.13+ which allows TEXT as internal temporary memory table instead of the disk temporary table Apr 16, 2019 at 11:02
  • Nice suggestion @RaymondNijland but I just switched to mysql 8 and mysql still loses connection. It really could have been that issue.
    – Bruno
    Apr 16, 2019 at 11:20
  • Additional information request. Post on pastebin.com and share the links. RAM size of your MySQL Host server A) complete (not edited) my.cnf or my.ini Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; E) complete MySQLTuner report AND Optional very helpful information, if available includes - htop OR top OR mytop for most active apps, ulimit -a for a linux/unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, for server tuning analysis. Apr 21, 2019 at 16:42

1 Answer 1

0

I couldnt find a direct solution to this problem. I read some posts explaining that sorting a subquery using fulltext might cause some memory issues.

However a workaround was to create a temporary table with the result of the subquery and sort it which works perfectly.

1
  • Bruno, could you post 'before' and 'after' solution that works perfectly? Thanks May 6, 2019 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.