Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 92207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:09:03+00:00 2026-05-10T23:09:03+00:00

SQL Server 2005 I have 10 million rows in DB, and run a select

  • 0

SQL Server 2005

I have 10 million rows in DB, and run a select (with lots of ‘where’ and joints.. pretty complex). The results are presented in grid (think goolge results) and because of that, the user cannot possibly use more then 1000 results.

So I limit my SQL with a TOP 1000.

Problem: User still wants to know that there are 5432 results for his search.

Can I get that info without paying the price (or in other words, with still getting the speed benefits the ‘top 1000’ is giving me ?)

Assumptions – Assume that the TOP 1000 brings 1000 out of 100K rows. So even the network price of moving 100K might be an issue.

Conclusions There is no free lunch! you can get the elegant way (accepted answer) but it still takes as long as the more expensive operation (i.e. counting all results). In real life, I will go with the 2 SQL approach, one to return top 1000 rows for display, and one that is ASYNC and updates some AJAX panel with the count(*) results that will take much much longer to computer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:09:03+00:00Added an answer on May 10, 2026 at 11:09 pm
    SELECT TOP 1000 x, y, z, COUNT(*) OVER () AS TotalCount FROM dbo.table 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server (2005) table which has nearly 100+ million rows in
On SQL Server 2005, I have a complex multi-level allocation process which looks like
SQL Server 2005 I have an SQL Function (ftn_GetExampleTable) which returns a table with
Using SQL Server 2005 I have a query that gets child records from bundles
[using SQL Server 2005] I have a table full of users, I want to
I'm using SQL Server 2005 I have a user. We'll call him User1. He
I'm using SQL Server 2005 and have the following T-SQL statement: DECLARE @MP VARCHAR(500)
I'm using SQL Server 2005 express I have a datetime field in a table
I'm working on SQL server 2005 and I have a very simple stored procedure:
Note: This issue appears to be limited to SQL Server 2005 SP2 I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.