Wednesday, March 28, 2012

Is There a Quick Way to Get a Total Match Count (estimate is OK) of a SQL FullText Query?

Hi,
I am using the June CTP release of SQL Server 2005 on Windows Sever 2003.
Is there a quick way to get a total natch count (estimate is OK)
of a SQL FullText query? I am working with about 10 million r
ows of simple character data.
The following SQL simply returns too slow due to disk IO on the disk
with the relational table when the number of hits is large (say half
millions)
select count(*) from CONTAINSTABLE(MyTableName, FTColumnName, '
"QueryPhrase" ')
Thanks,
Wenbin Zhang
Wenbin Zhang,
Since you're using SQL Server 2005, the best way to get this type of
statistical info is from the word list in the FT Catalog via the CIDump.exe
utility (see related thread subject: cidump documentation?) and import the
output back into a SQL Server table.
If you need to use a T-SQL to determine the word count of a SQL FTS query,
instead of just using a count(*), it is faster to use a stored proc, for
example:
create proc FTS_t1 (@.SearchWord varchar(7800))
as
select c1 from t1 where contains(c2, @.SearchWord)
go
create proc FTSCount_t1 (@.SearchWord varchar(7800))
as
set nocount on
create table #FTPrimaryKey(t1_UPK int)
insert into #FTPrimaryKey exec FTS_t1 @.SearchWord
select count(*) from #FTPrimaryKey
set nocount off
go
-- example of use:
exec FTSCount_t1 '"computer"'
Hope that helps!
John
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Wenbin Zhang" <zhang_wenbin@.hotmail.com> wrote in message
news:%23arzmzVoFHA.3696@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I am using the June CTP release of SQL Server 2005 on Windows Sever 2003.
> Is there a quick way to get a total natch count (estimate is OK)
> of a SQL FullText query? I am working with about 10 million r
> ows of simple character data.
> The following SQL simply returns too slow due to disk IO on the disk
> with the relational table when the number of hits is large (say half
> millions)
> select count(*) from CONTAINSTABLE(MyTableName, FTColumnName, '
> "QueryPhrase" ')
> Thanks,
> Wenbin Zhang
>

No comments:

Post a Comment