Page MenuHomePhabricator

Special:Recentchanges for logged-in users should use fewer sql queries
Closed, ResolvedPublic

Description

Viewing Special:Recentchanges as a logged-in user results in a huge amount of database queries. In particular, the following three queries are run for every row:

SELECT /* Title::loadRestrictions */ * FROM page_restrictions WHERE pr_page = '142'
SELECT /* Title::loadRestrictionsFromRow */ page_restrictions FROM page WHERE page_id = '142' LIMIT 1
SELECT /* Title::getLatestRevID */ page_latest FROM page WHERE page_id = '142' LIMIT 1

It should be easy to merge the first two queries. Also, the results aren't cached, which means that 5 changes to page_id 142 results in the aforementioned query block being run 5 times, each time with the exact same results.

Details

Reference
bz18229

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:35 PM
bzimport set Reference to bz18229.
bzimport added a subscriber: Unknown Object (MLST).

ayg wrote:

This should be merged into the main RC query. We shouldn't need caching here, it should just be part of the query we already do. At most these should be two or three extra queries per view, not per row.

The getLatestRevID is probably for rollback links. That feature (r45918) can just be killed if it's not easy to get it to work reasonably, IMO. The others probably can't just be removed, they look like permissions checks, but it should be possible to roll them into the existing query/queries.

While we're at it, Linker::link() is taking a huge amount of CPU time on RC, that should be investigated.

Didn't you fix some of this? What's still to do?

ayg wrote:

I didn't, someone else did (Domas, I think?). This might actually be fixed now, yes, in which case the bug can be closed.

matej_suchanek updated the task description. (Show Details)
matej_suchanek removed a subscriber: wikibugs-l-list.