Using "CONTAINS (Foo," A ") or CONTAINS (Foo," B ") versus CONTAINS (Foo," A "or" B ") in SQL Server FullText
I need to find some texts in a fairly large database with a full text index, and I don't know which is better to use in my variants of terms in a query.
I have seen several examples using
SELECT
Foo.Bar
FROM
Foo
WHERE
CONTAINS(Foo.Bar, "A") OR
CONTAINS(Foo.Bar, "B")
And some examples using
SELECT
Foo.Bar
FROM
Foo
WHERE
CONTAINS(Foo.Bar, '"A" OR "B"')
Which is better to use? And why?
+3
source to share
1 answer
Consolidating CONTAINS calls (your second example) will require less work. There is some overhead associated with each CONTAINS predicate, such as compiling a full text query, which can be limited. This is one of the recommendations made on TechNet .
With that being said, the difference may be negligible based on a number of factors such as index size, query, number of documents containing words in your query ...
+2
source to share