Most efficient way to search in SQL?

前端 未结 7 2000

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

    If you're using a query with LIKE '%term%' the indexes can't be used. They can be used only if you use a query like 'term%'. Think about an address book with tabs, you can find really fast contacts starting with letter L, but to find contacts with a on somewhere in the word, you've to scan the whole addressbook.

    The better alternative could be to use full text indexes:

    CREATE FULLTEXT INDEX title_desc
    ON table (title, description)
    

    And then in the query:

    SELECT title, description FROM table
    WHERE MATCH (title, description) AGAINST ('+Pizza')
    

提交回复
热议问题