-- 优化查询性能 ANALYZE TABLE customers; +---------------------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +---------------------+---------+----------+----------+ | sql_store.customers | analyze | status | OK | +---------------------+---------+----------+----------+
字符串索引
前缀索引
1 2
-- 以前20个字符做索引 CREATEINDEX idx_lastname ON customers (last_name(20))
全文索引
1 2 3 4 5 6 7 8 9 10 11
CREATE FULLTEXT INDEX idx_title_body ON posts (title, body);
-- 他会返回包括react或是redux的结果 SELECT *, WHERE MATCH(title, body)AGAINST('reactredux') FROM posts WHERE MATCH(title, body)AGAINST('reactredux');
-- 布尔模式 不要redux 要 form SELECT *, WHERE MATCH(title, body)AGAINST('reactredux') FROM posts WHERE MATCH(title, body)AGAINST('react -redux +form' IN BOOLEAN MODE);