Answer the question
In order to leave comments, you need to log in
SQL query grouping optimization?
There is a base ~ 64 GB.
SELECT
d.url,
GROUP_CONCAT(CONCAT(w.text, '[', wd.count, ']') SEPARATOR '; ') AS texts
FROM
words AS w
INNER JOIN words_in_domain AS wd ON w.id = wd.word
INNER JOIN domains AS d ON wd.domain = d.id
WHERE
w.text LIKE '%почин%' AND wd.count > 3
OR w.text LIKE '%вент%' AND wd.count > 2
GROUP BY
wd.domain
HAVING
texts LIKE '%почин%'
AND texts LIKE '%вент%'
-- COUNT(*) > 2
ORDER BY
NULL
Answer the question
In order to leave comments, you need to log in
Look towards full-text search. Start with regular in mysql. If it does not help, use a third-party search: elastic search, sphinx
like% something% will always slow down.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question