1

Right now I have the following construct to find items with similar keywords:

CREATE TEMPORARY TABLE tmp (FULLTEXT INDEX (keywords)) ENGINE=MyISAM
    SELECT object_id, keywords FROM object_search_de;

SELECT object_id
    FROM tmp
    WHERE MATCH (keywords) AGAINST ('foo,bar') > 1.045;

DROP TEMPORARY TABLE tmp;

So, depending on the amount of overall records and the average size of the keyword field, this can get really slow (over 60 seconds execution time). My goal would be to be within 1 second for this task.

Alternatively to keywords comma separated in a TEXT field, I do also have an atomic keyord table (meaning two columns keyword and object_id, directly associating one keyword with an item).

Are there any alternatives or smooth solutions to achieving the same effect without resorting to a MyISAM mirror table?

4

1 回答 1

0

首先,不要每次都创建表。您可以创建一次并使用触发器插入/更新/删除记录,或者如果您不想使用触发器,则可以定期(例如每小时)截断并插入记录。

或者,您可以从 MySQL 卸载此任务并使用 Lucene/Solr 或 Sphinx。

于 2013-09-16T13:43:44.490 回答