Full text search vs LIKE

前端 未结 6 1645
长情又很酷
长情又很酷 2021-02-04 01:45

My question is about using fulltext.As I know like queries which begin with % never use index :

SELECT * from customer where name like %username%
6条回答
  •  逝去的感伤
    2021-02-04 01:54

    Of what I know about fulltext indexes, i'll make the following extrapolations:

    1. Upon indexing, it parses the text, searching for words (some RDBMS, like MySQL, only consider words longer than 3 chars), and placing the words in the index.
    2. When you search in the fulltext index, you search for words, which then link to the row.
    3. If I'm right about the first two (for MSSQL), then it will only work if you search for WORDS, with lengths of 4 or more characters. It won't find 'armchair' if you look for 'chair'.

    Assuming all that is correct, I'll go ahead and make the following statement: The fulltext index is in fact an index, which makes search faster. It is large, and has fewer search posibilities than LIKE would have, but it's way faster.

    More info:
    http://www.developer.com/db/article.php/3446891
    http://en.wikipedia.org/wiki/Full_text_search

提交回复
热议问题