Most efficient way to search in SQL?

前端 未结 7 1999

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:42

    1. Did you create an index for title and for description?
    2. You should consider Sphinx for Full Text Search capabilities.

    Thanks for the comment Tyler.

    I restate my answer:

    1) Create an index on title and description columns, but your query would be limited to the example below, and that's not ideal for finding all relevant rows:

    SELECT * 
    FROM 'table' 
    WHERE title LIKE 'searcherm%' OR description LIKE 'searcherm%'
    LIMIT 20;
    

    2) As others have mentioned, use MySQL Full-Text Search, but you are limited to MyISAM table engine, as it isn't available for InnoDB. However, you can mix engines in MySQL, so you can make this table MyISAM, even if all your other tables are InnoDB.

    3) Use an external Full-Text Search engine, such as Sphinx. This will give you more relevant search results (MySQL Full-Text Search leaves much to be desired), it will perform better, and it abstracts the burden of Full-Text Searching away from your database.

提交回复
热议问题