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 8890939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:36:52+00:00 2026-06-14T22:36:52+00:00

I have a general software practice question, and maybe a moderator could better phrase

  • 0

I have a general software practice question, and maybe a moderator could better phrase my title.

I’m loading out a list of paged results for a “Manage Users” page that has a bunch of filters.

In my system, there are 3000 users, and I want to show 25 per page, with a pagination control at the bottom. No problem. Here’s the issue…

I want to show at the top of the page, that there say 2300 matches for my criteria, and so what I’m doing is running the same SQL query twice — once with a limit of 25 records to build into objects (for pagination), and then again to get the unconstrained total count.

This seems non-performant. Is there a preferred way of doing this without having to run TWO SQL queries?

  • 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. Editorial Team
    Editorial Team
    2026-06-14T22:36:53+00:00Added an answer on June 14, 2026 at 10:36 pm

    I solved a similar problem and went with the two query approach: the first query retrieved the current page of data (i.e., 25 rows), while the other one was used to retrieve the total count.

    From your question it seems as though you are retrieving the entire dataset in your second query. As others have said, you will be much better off retrieving only the row count instead.

    Grabbing only the row count in that second query should speed things up, but if you wanted to avoid running it each time you load some data, you could instead run it just once when the page is initially loaded, storing the result in the session or viewstate. This does of course mean that the count could become out of date if the number of rows changes, so you would need to evaluate the merits of accuracy against performance in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is about software architecture in general. Let's consider an example: We have
I have a general question on the class definition and its use..THe below code
I have a general question about interpreters of functional languages: Are there actually any
i have a general question : i'd like to develop a facebook application using
I have a general question about the new Django 1.3 static file framework. I
I have a general OOP question. If I have the following classes in C#
I have a general question that is rather open-ended (i.e. depends on platform, application
I have a general question for the group. I am about to start a
I have a general question about the way that database indexing works, particularly in
I have a general question about debugging a .NET process that has been built

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.