> 데이터 베이스 > MySQL 튜토리얼 > Fine-Tuning MySQL Full-Text Search with InnoDB_MySQL

Fine-Tuning MySQL Full-Text Search with InnoDB_MySQL

WBOY
풀어 주다: 2016-05-31 08:46:44
원래의
987명이 탐색했습니다.

If you are using FULLTEXT indexes in MySQL and plan to switch from MyISAM to InnoDB then you should review the reference manual section onFine-Tuning MySQL Full-Text Searchto see what configuration changes may be required. As I mentioned inyesterday’s postwhen comparing query results on my database with FULLTEXT indexes in MyISAM versus InnoDB I got different results. Specifically, the InnoDB tables were returning fewer results for certain queries with short FULLTEXT search terms. Here’s an example of a query that returned fewer results on InnoDB:

<code>select idfrom flite.ad_indexwhere match(name,description,keywords) against('+v1*' IN BOOLEAN MODE);</code>
로그인 후 복사

The issue was that all of the fine tuning I had done before was limited to MyISAM, so it didn’t affect InnoDB. In the past I configured MySQL FULLTEXT search to index words as short as 1 character (the default is 3), and to index common words (not to use any stopword list). These are the relevant variables I set in in my.cnf:

<code>ft_min_word_len = 1ft_stopword_file = ''</code>
로그인 후 복사

InnoDB has its own variables to control stopwords and minimum word length, so I needed to set these variables when I changed the tables from MyISAM to InnoDB:

<code>innodb_ft_min_token_size = 1innodb_ft_enable_stopword = OFF</code>
로그인 후 복사

Since those variables are not dynamic, I had to restart MySQL for them to take effect. Furthermore, I needed to rebuild the FULLTEXT indexes on the relevant tables. This is howthe manualinstructs you to rebuld the indexes:

To rebuild the FULLTEXT indexes for an InnoDB table, use ALTER TABLE with the DROP INDEX and ADD INDEX options to drop and re-create each index.

Rather than drop and recreate the indexes, I just usedALTER TABLE ... FORCEto rebuild the table (and indexes), like this:

<code>alter table flite.ad_index force;</code>
로그인 후 복사

After making those changes I re-ranpt-upgrade, and now I am getting the same set of rows back from MyISAM and InnoDB. The order of the rows is slightly different in some cases, but as I mentioned yesterday that isexpected behavior.

원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿