I have a stored procedure that searches for rows given a long list of parameters. Some of the queries result in extremely slow count
queries. Is it possible to stop counting after, say, one hundred rows so that I can simply display "100+" for the row count? It's not important that the users know exactly how many rows there are – especially when the result is in the thousands.
SQL Server – How to Perform Short Circuit Count Query
sql servert-sql
Related Question
- Sql-server – How to get paged resultset from a table
- Sql-server – Limit the number of results but show how much would be returned
- SQL Server – Count Aggregate Not Respecting Pivot Columns
- SQL Server 2014 Performance – Query Performance Depends on Database in Use
- SQL Server – Understanding Short Circuit in JOIN
- Sql-server – Counting occurrence of words in table is slow
Best Answer
Sure. A query like this should do the trick: