问题
I am using SQL Server 2012. A table has a text and a date column. The text column has a full-text index. The query issues CONTAINS against the full-text column but it also needs to include a greater-than condition on the date column. I am concerned about performance of SQL Server merging results from b-tree and full-text indices.
In Oracle, the performance aspect of this scenario is addressed by including "normal" columns (that are not subject to full-text search) into a full-text index (CTXCAT), so it's possible to set up a full-text index like that:
ctx_ddl.create_index_set('auction_set');
ctx_ddl.add_index ('auction_set', 'start_date');
and then query like that:
WHERE CATSEARCH (item_desc, '(toy dog) | "live animal"', 'start_date > ###') > 0
Is it possible to combine b-tree indices into full-text indices in SQL Server?
What is the most performant way to address the scenario of mixed (full-text & b-tree) querying in SQL Server?
Thanks.
回答1:
I don't believe you should experience any problem, if I understand your question correctly. I often combine full-text and b-tree with great results. When the full-text search is conducted, it is looking at each delimited "term" as an index, just as it would an indexed column with only one term (give or take some sql statistics). Either way, SQL must figure out its execution path. Full Text Search doesn't favor comparing integer/date values--more for matching strings of delimited data.
I would imagine you'd want to keep using the efficiency of the b-tree concept to your advantage. The full-text catalog index search appears to me to be a much more round-about search, although much more advantageous in situations using "LIKE" to parse/compare strings.
What I do is:
SELECT * FROM MyTable
WHERE CONTAINS(columnName, '"Toy Dog" OR "live animal"')
AND start_date > ###;
(see this msdn article for syntax info)
P.S. when full-text-indexing integer data, turn off the stoplist so that those values aren't ignored in the catalog indexing.
Hope any of that helps! (Nobody has answered so I thought I'd give my experience)
来源:https://stackoverflow.com/questions/12916958/mixed-queries-against-full-text-index