My aim is to make the following query faster.
SELECT SQL_NO_CACHE Links.id,Links.link,sum(ID_Links_Words.count) AS wordCount
FROM Links LEFT JOIN ID_Links_Words ON Links.id = ID_Links_Words.link
WHERE ID_Links_Words.word IN ('1025','1056','2353') GROUP BY Links.id
My table Links has the columns
id,link,title,description and timestamp
and the keys id (Primary),link (index), timestamp (index), (link,title,description) (fulltext)
The table ID_Links_Words has the columns
link, word, count
and the keys (link,word) (UNIQUE), link (index), word (index)
|id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 SIMPLE ID_Links_Words range link,link_2,word word 4 NULL 6 Using where; Using temporary; Using filesort|
|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 SIMPLE Links eq_ref PRIMARY PRIMARY 4 ID_Links_Words.link 1
|---------------------------------------------------------------------------------------------------------------------------------------------------------|
Sorry for this bad explain table :/ Hope you can read it.
I would like to get rid of the using temporary
and I'm not sure if it's possible. Are there any options to improve this sql statement? I might have to deal with about 100,000 words and 1,000 links.