J
J
Justique2015-12-21 15:58:03
MySQL
Justique, 2015-12-21 15:58:03

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

It is necessary to group by keywords, the problem is that the request just tightly lays down the server.
Help optimize.
UPD:
For example, the result of a request with a limit
761d8784812a4101b466990c94eb0f67.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2015-12-21
@melkij

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.

M
Max, 2015-12-21
@MaxDukov

do an EXPLAIN of your query.
LIKE on such a table will slow down, no options. FULL TEXT SEARCH - but brace yourself, the index can be hilarious.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question