Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Using 2 queries or just 1

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-12-26 : 13:01:43
Duane writes "First off, let me say that I am a relative newbie to SQL server as my question will reveal - but hey, we all have to start somewhere. Here is my question:
Is it better to use 2 short queries or 1 long one in terms of performance. Here are the details. We want to allow our customers to query a database of their orders, but limit them to 1000 rows. Should we use a Select count(*) query first to see if there are more than 1000 and then display a message if there are too many? Or, would it be better to execute the query without limitation, then only retrieve the first 1000 rows with another message saying there is more, but the results were too large. We want to use a stored procedure and not build the query in the code. However, if doing so would greatly improve performance, we would use this approach. Many of our customers have well over 20,000 records and we allow them to enter the date range they are requesting. On these customers, I suspect using the count first would be better. We also have customers that have only a small amount of orders and performing the count first seems wasteful. Any help or insight would be helpful. We are using SQLServer 7.0 sp2 on an NT4.0 sp 5 server."
   

- Advertisement -