Page MenuHomePhabricator

ApiQueryInfo::getProtectionInfo is slow on normalized templatelinks
Closed, ResolvedPublic

Description

From https://logstash.wikimedia.org/app/discover#/doc/logstash-*/logstash-mediawiki-2022.05.12?id=AMVFt4ABQPMIvrieGNfr

image.png (220×1 px, 24 KB)

On db1161 (dewiki)

SELECT /* ApiQueryInfo::getProtectionInfo  */  pr_type,pr_level,pr_expiry,page_title,page_namespace,lt_namespace,lt_title  FROM `page_restrictions`,`page`,`templatelinks` JOIN `linktarget` ON ((tl_target_id=lt_id))   WHERE ((lt_namespace = 10 AND lt_title IN ('De-ch','Falschschreibung','Hinweisbaustein','“','„') )) AND (pr_page = page_id) AND (pr_page = tl_from) AND pr_cascade = 1

Event Timeline

Ladsgroup renamed this task from ApiQueryInfo::getProtectionInfo is slow on normalized to ApiQueryInfo::getProtectionInfo is slow on normalized templatelinks.May 12 2022, 8:03 AM
Ladsgroup triaged this task as High priority.
Ladsgroup moved this task from Triage to In progress on the DBA board.

Change 791312 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] api: Force PRIMARY index on templatelinks for checking cascade protection

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

Some random queries you can try to check.

SELECT lt_namespace,lt_title  FROM`templatelinks` JOIN `linktarget` ON ((tl_target_id=lt_id))   WHERE ((lt_namespace = 10 AND lt_title IN ('De-ch','Falschschreibung','Hinweisbaustein','“','„') ));

 SELECT  pr_type,pr_level,pr_expiry,page_title,page_namespace,tl_namespace,tl_title  FROM `page_restrictions`,`page`,`templatelinks`    WHERE ((tl_namespace = 10 AND tl_title IN ('De-ch','Falschschreibung','Hinweisbaustein','“','„')) AND (pr_page = page_id) AND (pr_page = tl_from) AND pr_cascade = 1 ;

SELECT lt_id  FROM `linktarget` WHERE ((lt_namespace = 10 AND lt_title IN ('De-ch','Falschschreibung','Hinweisbaustein','“','„') ));

SELECT /* ApiQueryInfo::getProtectionInfo  */  pr_type,pr_level,pr_expiry,page_title,page_namespace  FROM `page_restrictions`,`page`,`templatelinks`   WHERE ((tl_target_id IN (44, 9792, 24, 45, 43) )) AND (pr_page = page_id) AND (pr_page = tl_from) AND pr_cascade = 1

One way to address this is to load the lt_target_id and avoid joining to linktarget altogether but then you have keep the id in place so you wouldn't need to get lt_title and lt_namespace.

Change 791316 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] RestrictionStore: Add support for templatelinks migration

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

Change 791252 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@wmf/1.39.0-wmf.10] ApiQueryInfo: Force PRIMARY index on templatelinks

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

Change 791253 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@wmf/1.39.0-wmf.11] ApiQueryInfo: Force PRIMARY index on templatelinks

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

Change 791312 merged by jenkins-bot:

[mediawiki/core@master] ApiQueryInfo: Force PRIMARY index on templatelinks

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

Change 791253 merged by jenkins-bot:

[mediawiki/core@wmf/1.39.0-wmf.11] ApiQueryInfo: Force PRIMARY index on templatelinks

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

Change 791252 merged by Ladsgroup:

[mediawiki/core@wmf/1.39.0-wmf.10] ApiQueryInfo: Force PRIMARY index on templatelinks

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

Mentioned in SAL (#wikimedia-operations) [2022-05-12T12:30:52Z] <ladsgroup@deploy1002> Synchronized php-1.39.0-wmf.10/includes/api/ApiQueryInfo.php: Backport: [[gerrit:791252|ApiQueryInfo: Force PRIMARY index on templatelinks (T308207)]] (duration: 00m 50s)

Change 791316 merged by jenkins-bot:

[mediawiki/core@master] RestrictionStore: Add support for templatelinks migration

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

Change 791745 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@wmf/1.39.0-wmf.11] RestrictionStore: Add support for templatelinks migration

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

Change 791745 merged by jenkins-bot:

[mediawiki/core@wmf/1.39.0-wmf.11] RestrictionStore: Add support for templatelinks migration

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

Change 792126 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@wmf/1.39.0-wmf.10] RestrictionStore: Add support for templatelinks migration

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

Change 792126 merged by jenkins-bot:

[mediawiki/core@wmf/1.39.0-wmf.10] RestrictionStore: Add support for templatelinks migration

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

Mentioned in SAL (#wikimedia-operations) [2022-05-16T11:09:15Z] <ladsgroup@deploy1002> Synchronized php-1.39.0-wmf.10/includes: Backport: [[gerrit:792126|RestrictionStore: Add support for templatelinks migration (T308207)]] (duration: 00m 54s)

Ladsgroup moved this task from In progress to Done on the DBA board.