From de1aefd55cd5cd7a950df72cce5f97d3dbff5ff6 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Wed, 17 Apr 2013 18:23:11 -0300 Subject: [PATCH] Make UserCache only look up a user once. I noticed on special:listfiles/username, UserCache was doing queries like select user_whatever from user where user_id in ( '1', '1', ...) with the same user id 50 times (one for each result returned in the special page). That seemed a little insane, so put the list of users to query through a array_unique. (Quite likely the db would optimize that query to not literally look up the same user 50 times, but nonetheless it seems better to filter the list before then) Change-Id: I80c8a359d0f7a53b2420ebcda641e594dd3c56e9 --- includes/cache/UserCache.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/cache/UserCache.php b/includes/cache/UserCache.php index 694c1a142c..63d4141e3c 100644 --- a/includes/cache/UserCache.php +++ b/includes/cache/UserCache.php @@ -81,6 +81,8 @@ class UserCache { $usersToCheck = array(); $usersToQuery = array(); + $userIds = array_unique( $userIds ); + foreach ( $userIds as $userId ) { $userId = (int)$userId; if ( $userId <= 0 ) { -- 2.20.1