我有3张桌子
只查询table3,只需要0.04秒。
select * from table3
WHERE MATCH (title,content)
AGAINST ('+words' IN BOOLEAN MODE)
ORDER BY pid
Run Code Online (Sandbox Code Playgroud)
但是像这样查询,花费 16.87 秒。
SELECT *
FROM table1
INNER JOIN table2 ON table1.pid = table2.pid
LEFT JOIN table3 ON table1.pid = table3.pid
WHERE MATCH (table3.title, table3.content)
AGAINST ('+words' IN BOOLEAN MODE)
ORDER BY table3.pid
Run Code Online (Sandbox Code Playgroud)
我为第二个查询制定了一个解释计划,返回:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE table1 …
Run Code Online (Sandbox Code Playgroud)