2012年3月27日星期二

Full Text Search resultset count

For performance reasons I am limiting the resultset to 100 rows. However, I would like to have the performance but need the total count of rows found. How can I keep the performance gain from limiting to top 100 and still get the total count.

Could I do something like this:

select top 100 count(id), field1, field2, field3 from ....

Would this return 100 in the count field?

Thanks

I think T-SQL does not support above sematic. field1, field2, ... will need to be part of group by or aggregate function.

Back to you problem, it seems like you want to know total hit count and want it performs well. The problem is that to get total hit count it requires to get the whole result set which is major part of the cost. By using top 100 really will not save you much. If you can remove the requirement to get total hit count, you can then use containstable with a top_n parameter, it will save you a lot for full-text search part.

thanks,

jingwei

没有评论:

发表评论