The table xx_user_detail, user_id is int primary index, site1-site9 is combined fulltext index, the total row count is 5 million
SELECT * FROM xx_user_detail WHERE (user_id=14) AND MATCH (site1,site2,site3,site4,site5,site6,site7,site8,site9) AGAINST ('苏娟的食品店');
this SQL1 use 0.3s
SELECT * FROM xx_user_detail WHERE (user_id=14 or user_id=15) AND MATCH (site1,site2,site3,site4,site5,site6,site7,site8,site9) AGAINST ('苏娟的食品店');
this SQL2 use 2.5s
1 Why SQL2 so slowly than SQL1 by just add one row? How to improve SQL2?
2 The SQL1, use 0.3s for just scan one row, is it normal? If not, how to improve it?
the table structure is:
CREATE TABLE xx_user_detail (
user_id int(11) NOT NULL,
site1 varchar(20) NOT NULL,
site2 varchar(20) NOT NULL,
site3 varchar(20) NOT NULL,
site4 varchar(20) NOT NULL,
site5 varchar(20) NOT NULL,
site6 varchar(20) NOT NULL,
site7 varchar(20) NOT NULL,
site8 varchar(20) NOT NULL,
site9 varchar(20) NOT NULL,
PRIMARY KEY (user_id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
ALTER TABLE xx_user_detail ADD FULLTEXT INDEX the_site_index(site1,site2,site3,site4,site5,site6,site7,site8,site9) WITH PARSER ngram;
SELECT * FROM (SELECT * FROM xx_user_detail WHERE (user_id=14 or user_id=15)) as tbl where MATCH (site1,site2,site3,site4,site5,site6,site7,site8,site9) AGAINST ('苏娟的食品店');MyISAM, I suggest switching toInnoDB