, . , EXPLAIN FORMAT=JSON SELECT ... .
, , . ( , .)
-, . 3 FT , (UNION) question_ids .
( SELECT question_id,
MATCH (... ) as relevance
FROM questions
WHERE MATCH (questiontext, ...) AGAINST ... )
UNION ALL
( SELECT am.question_id,
MATCH (... ) as relevance
FROM answers AS a
JOIN answer_mapping AS am ON am.answerid = a.id
WHERE MATCH (a.answertext) AGAINST ... )
UNION ALL
( SELECT tm.question_id,
MATCH (... ) as relevance
FROM tags AS t
JOIN tagsmapping tm ON ...
WHERE MATCH (t.tag) AGAINST ... )
, FT question_id.
:
SELECT question_id,
MAX(relevance)
FROM ( that query ) AS q1
GROUP BY question_id
ORDER BY relevance DESC
LIMIT 20
"" question_ids, ...
, :
SELECT ....
( SELECT login FROM users WHERE q.userid = id ) AS username
FROM ( the intermediate query ) AS q2
JOIN questions AS q
questions q.spam < 10
ORDER BY q2.relevance
Yes, it is JOINingback to questions, but it turns out to be faster.
Please note that GROUP BYis not listed here. And if there was an internal request LIMIT, it will not be needed here.
I apologize if I did not quite understand everything correctly; there were more conversions than I expected.
source
share