Raoni Zacaron
Raoni Zacaron

Reputation: 367

Use of 'CONTAINS(Foo, "A") OR CONTAINS(Foo, "B") vs CONTAINS(Foo, '"A" OR "B"') in SQL Server FullText

I need to find some texts in a pretty huge database full text indexed, and i dont know what is better to use in my variations of the terms in the query.

I have saw some 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"')

What is better to use? And why?

Upvotes: 3

Views: 153

Answers (1)

Keith
Keith

Reputation: 21264

Consolidating calls to CONTAINS (your 2nd example) is going to require less work. There is some overhead involved with each CONTAINS predicate, like the compilation of the full text query, that can be limited. This is one of the recommendations made on TechNet.

With that said, the difference may be negligible based on a number of factors like the index size, the query, the number of documents that contain the words in your query...

Upvotes: 2

Related Questions