I have a situation where I would like to search a single word.
For that scenario, which query would be good from a performance point of view?
Full Text Searching (using the CONTAINS) will be faster/more efficient than using LIKE with wildcarding. Full Text Searching (FTS) includes the ability to define Full Text Indexes, which FTS can use. Dunno why you wouldn't define a FTS index if you intended to use the functionality...
LIKE with wildcarding on the left side (IE: LIKE '%Search'
) can not use an index (assuming one exists for the column), guaranteeing a table scan. I haven't tested & compared, but regex has the same pitfall. To clarify, LIKE '%Search'
and LIKE '%Search%'
can not use an index; LIKE 'Search%'
can use an index.
For a typical database, the CONTAINS search can be much faster assuming the appropriate full text search index is built on the field being searched. The evaluation of the LIKE
operator generally doesn't use an index and thus must read all the data.
Like search on Table it self, will kill the performance. Better to apply like search on CTE.