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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:34:36+00:00 2026-06-07T18:34:36+00:00

Im in a dilema on which one of these methods are most efficient. Suppose

  • 0

Im in a dilema on which one of these methods are most efficient.

Suppose you have a query joining multiple tables and querying thousand of records. Than, you gotta get the total to paginate throughout all these results.

Is it faster to?

1) Do a complete select (suppose you have to select 50’s columns), count the rows and than run another query with limits? (Will the MySQL cache help this case already selecting all the columns you need on the first query used to count?)

2) First do the query using COUNT function and than do the query to select the results you need.

3) Instead of using MySQL COUNT function, do the query selecting the ID’s for example and use the PHP function mysql_num_rows?

  • I think the number 2 is the best option, using MySQL built in COUNT function, but I know MySQL uses cache, so, selecting all the results on first query gonna be faster?

Thanks,

  • 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-07T18:34:38+00:00Added an answer on June 7, 2026 at 6:34 pm

    Have a look at Found_Rows()

    A SELECT statement may include a LIMIT clause to restrict the number
    of rows the server returns to the client. In some cases, it is
    desirable to know how many rows the statement would have returned
    without the LIMIT, but without running the statement again. To obtain
    this row count, include a SQL_CALC_FOUND_ROWS option in the SELECT
    statement, and then invoke FOUND_ROWS() afterward:

    mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name WHERE id > 100 LIMIT 10;
    mysql> SELECT FOUND_ROWS();

    The second SELECT returns a number indicating how many rows the first SELECT`
    would have returned had it been written without the LIMIT clause.

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

Sidebar

Related Questions

The problem I have multiple groups which specify the relationships of symbols.. for example:
There is one aspect of TDD which I never fully understood. Suppose somebody asked
I have an interesting dilemma to which, I hope, someone may have an answer.
I have a dilema, I want to present to the user a semi-transparent view.
I have got a designing dilema. I have a class named UserAccount that represent
I have a conceptual Python design dilemma. Say I have a City class, which
I have a java project I want to create which will be built on
I have a dilema and wonder what is business best practice. I'm using Uploadify
In a bit of a dilemma. I have tables Schools , Projects , Sponsors
I have a dilemma, maybe you can help me. I have a table which

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.