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

  • Home
  • SEARCH
  • 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 791135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:47:18+00:00 2026-05-14T21:47:18+00:00

For my application most of my SQL queries return a specified number of rows.

  • 0

For my application most of my SQL queries return a specified number of rows. I’d also like to get the maximum possible number of results i.e. how many rows would be returned if I wasn’t setting a LIMIT.

Is there a more efficient way to do this (using just SQL?) than returning all the results, getting the size of the result set and then splicing the set to return just the first N rows.

  • 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-05-14T21:47:18+00:00Added an answer on May 14, 2026 at 9:47 pm

    You can use SELECT COUNT(*), but this isn’t ideal for large data sets.
    A more efficient solution is to use SQL_CALC_FOUND_ROWS and FOUND_ROWS():
    http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows

    First query:

    SELECT SQL_CALC_FOUND_ROWS id, name, etc FROM table LIMIT 10;

    Second query:

    SELECT FOUND_ROWS();

    You’ll still need two queries, but you run the main query once, saving resources.

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

Sidebar

Related Questions

I have a particular web application that like most others, has to account for
I have an ASP.Net Application that uses a SQL Server database. I am also
I am building an application where most of the HTML is built using javascript.
I have an application in which most requests are submitted via AJAX, though some
I have a large Compact Frameworks V2.0 application that in most cases works very
I've written (most of) an application in Flex and I am concerned with protecting
My application is running on Google App Engine and most of requests constantly gets
Most of the literature on Virtual Memory point out that the as a Application
I created just the most basic WCF Service Application to do some prototyping, but
I am working on an application that detects the most prominent rectangle in an

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.