Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count rows only if needed #14607

Closed
mvorisek opened this issue Sep 6, 2018 · 1 comment · Fixed by #14821
Closed

Count rows only if needed #14607

mvorisek opened this issue Sep 6, 2018 · 1 comment · Fixed by #14821
Assignees
Labels
enhancement A feature request for improving phpMyAdmin has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete help wanted
Milestone

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Sep 6, 2018

Currently the PhpMyAdmin counts the total rows of a query result every time when LIMIT is not present.

If LIMIT is not presented in the user query, default LIMIT (like LIMIT 0, 50) is appended to the query.

But currently the total rows count is queried even when the total rows are below the default limit. This is not needed as has very large impact on long running queries.


Example:

User query:

SELECT count(*) tablewith10megrows


PhpMyAdmin sends to DB:

SELECT count(*) tablewith10megrows LIMIT 0, 50

and gets exactly one row.

But the PhpMyAdmin sends additional unneeded query:

SELECT SQL_CALC_FOUND_ROWScount(*) tablewith10megrows

which is never needed if the rows count of the previous query was below the limit (exactly below max. count as LIMIT clause can have offset).

@williamdes williamdes added enhancement A feature request for improving phpMyAdmin help wanted labels Nov 20, 2018
@dhyey35
Copy link
Contributor

dhyey35 commented Dec 28, 2018

@williamdes I will try to solve this issue and will ask for your help if needed

@williamdes williamdes added the has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete label Dec 28, 2018
MauricioFauth pushed a commit that referenced this issue Mar 5, 2019
Signed-off-by: Dhyey Thakore <dhyey35@gmail.com>
MauricioFauth pushed a commit that referenced this issue Mar 5, 2019
Signed-off-by: Dhyey Thakore <dhyey35@gmail.com>
(cherry picked from commit feca784)
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
MauricioFauth added a commit that referenced this issue Mar 5, 2019
[ci skip]

Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
@MauricioFauth MauricioFauth self-assigned this Mar 5, 2019
@MauricioFauth MauricioFauth added this to the 4.8.6 milestone Mar 5, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement A feature request for improving phpMyAdmin has-pr An issue that has a pull request pending that may fix this issue. The pull request may be incomplete help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants