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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:56:37+00:00 2026-05-10T21:56:37+00:00

I have a dataset in MySQL where using limit is already an expensive query,

  • 0

I have a dataset in MySQL where using limit is already an expensive query, and finding the number of results is expensive as well. Thus, I’d like to avoid doing another query to find the number of results. I cannot use MYSQL_CALC_FOUND_ROWS because the limit is inside a subquery:

SELECT * FROM items, (   SELECT     item_id   FROM     (etc)   WHERE     some.field=<parameter>   AND (etc)   GROUP BY (something)   ORDER BY (something_else) DESC   LIMIT 15 ) subset WHERE item.id=subset.item_id 

I could left join items and do away with the subquery, then be able to use MYSQL_CALC_FOUND_ROWS, however this is very, very, slow. I’ve tried all index optimizations and let’s just assume it is out of the question.

This now becomes more a design question… how do I allow the user to page through this data when I don’t know the last page? I only know if they’ve gone too far (eg: query returns no results).

  • 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-10T21:56:37+00:00Added an answer on May 10, 2026 at 9:56 pm

    Here’s a summary of an article by MySQL guru Baron Schwartz:

    http://www.mysqlperformanceblog.com/2008/09/24/four-ways-to-optimize-paginated-displays/

    Four Ways to Optimize Paginated Displays

    1. On the first query, fetch and cache all the results.

    2. Don’t show all results. Not even Google lets you see the millionth result.

    3. Don’t show the total count or the intermediate links to other pages. Show only the ‘next’ link.

    4. Estimate how many results there are. Again, Google does this and nobody complains.

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

Sidebar

Related Questions

I am using asp.net + Mysql. I have multiple rows in my dataset; I
I have a dataset obtained from MySQL that goes like this: Array ( [0]
I'm using groovy gsql to query to Mysql database. Everything goes well on localhost
I have created a crystal report using MySql 5.1, using XML (Dataset save as
I have an sql query (MyQSL DB, using .Net's SqlClient) that returns a dataset.
I have a dataset something like this: col_a col_b col_c 1 abc_boy 1 2
I have created one Windows Forms application with C# and MySQL (using MySQL Connector
I'm using MySql and am pretty new to it. I have a table which
Development language and DB: PHP/MySQL I have a table geo_places with something like 8
I have a data set from mysql in a multidimensional array. I am using

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.