r***@gmail.com
2006-12-19 03:07:07 UTC
Please help me optimize this:
I have a table with columns: headlineid, keyword.
headlineid+keyword combination is unique.
Relationship between headline and keyword is many-to-many. i.e.,
headlines can have many keywords. keywords can be associated with many
headlines.
Keywords in the same headline are considered "related".
Here's the query to find out which keywords 'hello' is related to and
sort desc on number of occurrences of the related keywords:
select keyword, count(keyword) as keywordcount from tags where
headlineid in (select distinct(headlineid) from tags where keyword =
'hello') AND keyword <> 'hello' group by keyword order by keywordcount
desc limit 0, 5;
This query takes a lot of time. Need help with optimization. All help
is appreciated.
I have a table with columns: headlineid, keyword.
headlineid+keyword combination is unique.
Relationship between headline and keyword is many-to-many. i.e.,
headlines can have many keywords. keywords can be associated with many
headlines.
Keywords in the same headline are considered "related".
Here's the query to find out which keywords 'hello' is related to and
sort desc on number of occurrences of the related keywords:
select keyword, count(keyword) as keywordcount from tags where
headlineid in (select distinct(headlineid) from tags where keyword =
'hello') AND keyword <> 'hello' group by keyword order by keywordcount
desc limit 0, 5;
This query takes a lot of time. Need help with optimization. All help
is appreciated.