I have tested several โCost of inquiryโ monitoring tests in terms of actual execution.
It appears that the total cost of CONTAINSTABLE over any number of words associated with "AND" in the search phrase is equal to the value of the smallest popular only of these words.
The total cost of CONTAINSTABLE over any number of words connected with "OR" is equal to the cost of the most popular only for these words.
This suggests that the full-text search engine prioritizes the words from the search string according to their popularity (number of occurrences) in the index. Therefore, I think that trying to pre-arrange the search strings on the client will not be of any use.
Here are my full-text search tests:
Declare @Word1 nvarchar(50) = N'"Word1*"'; Declare @Word2 nvarchar(50) = N'"Word2*"'; Declare @SearchString nvarchar(100) = ''; PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' Start'; Set @SearchString = @Word1; Select * From CONTAINSTABLE([Table], [Field], @SearchString); PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' ' + @SearchString; Set @SearchString = @Word2; Select * From CONTAINSTABLE([Table], [Field], @SearchString); PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' ' + @SearchString; Set @SearchString = @Word1 + ' AND ' + @Word2; Select * From CONTAINSTABLE([Table], [Field], @SearchString); PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' ' + @SearchString; Set @SearchString = @Word2 + ' AND ' + @Word1; Select * From CONTAINSTABLE([Table], [Field], @SearchString); PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' ' + @SearchString; Set @SearchString = @Word1 + ' OR ' + @Word2; Select * From CONTAINSTABLE([Table], [Field], @SearchString); PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' ' + @SearchString; Set @SearchString = @Word2 + ' OR ' + @Word1; Select * From CONTAINSTABLE([Table], [Field], @SearchString); PRINT SUBSTRING(CONVERT(varchar, SYSDATETIME(), 121), 12, 11) + ' ' + @SearchString;
Please replace [Table], [Field]
with the actual tables and field names marked with full text, and set @Word1
and @Word2
in the popular and back words from your dataset.