実際のデータを使用したパフォーマンス テスト
t1 => 100,000 行および増加中
t2 => 207 行
テスト1
SELECT
t2.fullname,
count(t1.id) AS total
FROM
table_1 AS t1
RIGHT JOIN
table_2 AS t2 ON t1.text REGEXP t2.keyword
GROUP BY t2.fullname
ORDER BY total DESC
212 seconds
テスト 2
SELECT
t2.fullname,
count(t1.id) AS total
FROM
table_1 AS t1
RIGHT JOIN
table_2 AS t2 ON t1.text LIKE CONCAT('%', t2.keyword, '%')
GROUP BY t2.fullname
ORDER BY total DESC
30 seconds
テスト 3
SELECT
t2.fullname,
count(t1.id) AS total
FROM
table_1 AS t1
RIGHT JOIN
table_2 AS t2 ON t1.text LIKE lower(CONCAT('%', t2.name, '%')) AND t1.text LIKE lower(CONCAT('%', t2.surname, '%'))
GROUP BY t2.fullname
ORDER BY total DESC
32 seconds
テスト 4
SELECT
t2.fullname,
count(t1.id) AS total
FROM
table_1 AS t1
RIGHT JOIN
table_2 AS t2 ON t1.text LIKE lower(CONCAT('%', t2.name, '%')) OR t1.text LIKE lower(CONCAT('%', t2.surname, '%'))
GROUP BY t2.fullname
ORDER BY total DESC
40 seconds
テスト5
SELECT
t2.fullname,
count(t1.id) as total
FROM
table_1 as t1
RIGHT JOIN
table_2 as t2 ON t1.text LIKE CONCAT('%', t2.keyword, '%') OR (t1.text LIKE lower(CONCAT('%', t2.name, '%')) AND t1.text LIKE lower(CONCAT('%', t2.surname, '%')))
GROUP BY t2.fullname
ORDER BY total DESC
41 seconds
テスト 5 を選択します。最良の妥協結果/パフォーマンス
さらにアドバイスはありますか?
ご協力いただきありがとうございます。