Page MenuHomePhabricator

Allow to define expectation for queries per caller on TransactionProfiler
Open, Needs TriagePublicFeature

Description

Feature summary (what you would like to be able to do and where):
MediaWiki has some function that lazy load data and this could be called on each row of a listing page, this results in many calls to the database with individual selects, all coming from the same caller. There are often also batch alternatives, for example, to avoid many calls from MediaWiki\Page\LinkCache::fetchPageRow it is better to use a LinkBatch in this situation to batch the query.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):
Reduce database load and create the html of the page faster.

Benefits (why should this be implemented?): Page views are faster, less timeout that could overload the database

Event Timeline

Change #1287935 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] Rdbms: Allow expectation for queries per caller on TransactionProfiler

https://gerrit.wikimedia.org/r/1287935

Change #1287935 merged by jenkins-bot:

[mediawiki/core@master] Rdbms: Allow expectation for queries per caller on TransactionProfiler

https://gerrit.wikimedia.org/r/1287935

It is possible that not all queries can use batching and single queries are needed for different pages, for example T121063: Fix Linker::getRollbackEditCount query spam in Special:RecentChanges and Special:Contributions
That would make this expectation harder to apply in a generic way, but could be bypassed by varying the caller name by page id as indicator, that the query is okay.

Some code trigger multiply, but different, queries in a function with the same caller name (maintenance script with all code in execute function; function that avoid join and read the extra data with a second query), but could be bypassed by splitting into more functions and using that caller name.
maintenance script sometimes also special about the calls, as running the same query repeatly, but with pagination, that get added in the count.