Users queries can skip the SQL_CALC_FOUND_ROWS queries

Open
#136 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
php
Domain
databases

Research direction

Start by reproducing the query sequence shown in the issue and review the linked wporg-mu-plugins pull request for context. Trace how HyperDB handles SQL_CALC_FOUND_ROWS before SELECT FOUND_ROWS(); done means the sequence no longer raises the reported error and the found-row result is returned.

Written by the indexing model from the issue text.

Description

Running a query such as the following, followed by a SELECT FOUND_ROWS() will result in an error, and the found rows not being returned.

SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_users.ID FROM wp_users WHERE 1....

results in this error:

Attempted SELECT FOUND_ROWS() without prior SQL_CALC_FOUND_ROWS.

For an example of code that can trigger this, see https://github.com/WordPress/wporg-mu-plugins/pull/412

Dominant language
PHP
Stars
150
Forks
28
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Automattic/HyperDB

All issues in Automattic/HyperDB

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.