Question

When should I use Full-Text Search instead of using a LIKE search, such as

SELECT * FROM myTABLE WHERE myCOLUMN LIKE '*something'

Was it helpful?

Solution

From MSDN - Full Text Search Overview:

"Full-text queries perform linguistic searches against text data in full-text indexes by operating on words and phrases based on rules of a particular language such as English or Japanese. Full-text queries can include simple words and phrases or multiple forms of a word or phrase.

Full-text search is applicable in a wide range of business scenarios such as e-businesses—searching for items on a web site; law firms—searching for case histories in a legal-data repository; or human resources departments—matching job descriptions with stored resumes. The basic administrative and development tasks of full-text search are equivalent regardless of business scenarios. However, in a given business scenario, full-text index and queries can be honed to meet business goals. For example, for an e-business maximizing performance might be more important than ranking of results, recall accuracy (how many of the existing matches are actually returned by a full-text query), or supporting multiple languages. For a law firm, returning every possible hit (total recall of information) might be the most important consideration."

Comparison of LIKE to Full-Text Search

"In contrast to full-text search, the LIKE Transact-SQL predicate works on character patterns only. Also, you cannot use the LIKE predicate to query formatted binary data. Furthermore, a LIKE query against a large amount of unstructured text data is much slower than an equivalent full-text query against the same data. A LIKE query against millions of rows of text data can take minutes to return; whereas a full-text query can take only seconds or less against the same data, depending on the number of rows that are returned."

So the main difference is the type of search that they do: full text is about word search, while LIKE is about character search. I would personally use full text search on tables where I have big amounts of human text - usually big columns (big descriptions, exceeding the standard 8k characters) in big tables (millions of rows). Need to keep in mind the added administration for FTS (create catalogs, indexes, update them when needed).

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top