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

The Archive Base Latest Questions

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

I am building a php site using jquery and the DataTables plugin. My page

  • 0

I am building a php site using jquery and the DataTables plugin. My page is laid out just as it needs to be with pagination working but in dealing with large datasets, I have noticed the server is pulling ALL returned rows as opposed to the 10 row (can be more) limit stated within each ‘page’.

Is it possible to limit the results of a query and yet keep say the ID numbers of those results in memory so when page 2 is hit (or the result number is changed) only new data is sought after?

Does it even make sense to do it this way?

I just dont want to query a DB with 2000 rows returned then have a ‘front-end-plugin’ make it look like the other results are hidden when they are truthfully on the page from the start.

  • 1 1 Answer
  • 1 View
  • 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-18T03:47:32+00:00Added an answer on May 18, 2026 at 3:47 am

    The LIMIT clause in SQL has two parts — the limit and the offset.

    To get the first 10 rows:

    SELECT ... LIMIT 0,10
    

    To get the next 10 rows:

    SELECT ... LIMIT 10,10
    

    To get the next 10 rows:

    SELECT ... LIMIT 20,10
    

    As long as you ORDER the result set the same each time, you absolutely don’t have to (and don’t want to) first ask the database to send you all 2000 rows.

    To display paging in conjunction with this, you still need to know how many total rows match your query. There are two ways to handle that —

    1) Ask for a row count with a separate query

    SELECT COUNT(*) FROM table WHERE ...
    

    2) Use the SQL_CALC_FOUND_ROWS hint in your query, which will tell MySQL to calculate how many rows match the query before returning only the 10 you asked for. You then issue a SELECT FOUND_ROWS() query to get that result.

    SELECT SQL_CALC_FOUND_ROWS column1, column2 ... LIMIT 0,10
    

    2 is preferable since it does not add an extra query to each page load.

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

Sidebar

Related Questions

building a site using PHP and MySQL that needs to store a lot of
I'm building a jQuery Mobile site, using PHP to interact with a MySQL database
I'm building a PHP site, but for now the only PHP I'm using is
I am considering building a site using php, but there are several aspects of
I'm building a site using symfony php framework. I have a link in my
I am building a static site using php files. On the index.php file, I
I'm building a site like SO using PHP as a personal project. I started
I am building a modular framework for a PHP MVC site. I am using
All, I am building a small site using PHP. In the site, I receive
I am a newbie with zend. On the web-site i am building using zend/php,

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.