Most efficient way to search in SQL?

前端 未结 7 2002

I have a database with 75,000+ rows with 500+ entries added per day.

Each row has a title and description.

I created an RSS feed which gives you the latest entri

7条回答
  •  孤城傲影
    2021-02-08 08:44

    Try:

    SELECT * FROM table
    WHERE MATCH (title,description) AGAINST (searchterm);
    

    Make sure you add a full text index on title, description together.

    Dont try to reinvent the wheel. MATCH and AGAINST are provided by mysql to do exactly that and to make your life easy. However, note full text search works on MyISAM tables. You can workaround for InnoDb too. You can simply add FT index by altering table like:

    ALTER TABLE table ADD FULLTEXT(title,description);
    

提交回复
热议问题