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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:27:46+00:00 2026-05-16T17:27:46+00:00

A table with about 70K records is displayed on a site, showing 50 records

  • 0

A table with about 70K records is displayed on a site, showing 50 records per page.
Pagination is done with limit offset,50 on the query, and the records can be ordered on different columns.

Browsing the latest pages (so the offset is around 60,000) makes the queries much slower than when browsing the first pages (about 10x)

Is this an issue of using the limit command?
Are there other ways to get the same 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. Editorial Team
    Editorial Team
    2026-05-16T17:27:47+00:00Added an answer on May 16, 2026 at 5:27 pm

    With large offsets, MySQL needs to browse more records.

    Even if the plan uses filesort (which means that all records should be browsed), MySQL optimizes it so that only $offset + $limit top records are sorted, which makes it much more efficient for lower values of $offset.

    The typical solution is to index the columns you are ordering on, record the last value of the columns and reuse it in the subsequent queries, like this:

    SELECT  *
    FROM    mytable
    ORDER BY
            value, id
    LIMIT 0, 10
    

    which outputs:

    value  id
    
    1      234
    3      57
    4      186
    5      457
    6      367
    8      681
    10     366
    13     26
    15     765
    17     345  -- this is the last one
    

    To get to the next page, you would use:

    SELECT  *
    FROM    mytable
    WHERE   (value, id) > (17, 345)
    ORDER BY
            value, id
    LIMIT 0, 10
    

    , which uses the index on (value, id).

    Of course this won’t help with arbitrary access pages, but helps with sequential browsing.

    Also, MySQL has certain issues with late row lookup. If the columns are indexed, it may be worth trying to rewrite your query like this:

    SELECT  *
    FROM    (
            SELECT  id
            FROM    mytable
            ORDER BY
                    value, id
            LIMIT   $offset, $limit
            ) q
    JOIN    mytable m
    ON      m.id = q.id
    

    See this article for more detailed explanations:

    • MySQL ORDER BY / LIMIT performance: late row lookups
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a table with about 200,000 records. i want to add a field
I have a table with about 100k records and I want to delete some
I've a table with about 130 000 records with telephonenumbers. The numbers are all
I have a table with about 1000 records and 2000 columns. What I want
I have a table with about 20+ million records. Structure is like: EventId UNIQUEIDENTIFIER
I have a titles table of about 14000 records, with a float field average_rating
Has anyone generated a big, really big table about a millions records using this
I've got a table with about 1 million records (running SQL Server 2008 Web).
my first table has about 18K records so when i select * from table2
I have a big MySQL InnoDB table (about 1 milion records, increase by 300K

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.