From: Roan Kattouw Date: Sun, 3 Jan 2010 20:12:59 +0000 (+0000) Subject: API: Per Domas, don't FORCE INDEX when doing an INNER JOIN with the user_groups table X-Git-Tag: 1.31.0-rc.0~38426 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=e91308e012d7740535f585bcc5ada2a4175b1aa0;p=lhc%2Fweb%2Fwiklou.git API: Per Domas, don't FORCE INDEX when doing an INNER JOIN with the user_groups table --- diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index fa0548fe99..ba7dd1fb01 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -56,6 +56,7 @@ class ApiQueryAllUsers extends ApiQueryBase { $limit = $params['limit']; $this->addTables('user', 'u1'); + $useIndex = true; if (!is_null($params['from'])) $this->addWhere('u1.user_name >= ' . $db->addQuotes($this->keyToTitle($params['from']))); @@ -75,6 +76,7 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addWhere('user_editcount > 0'); if ($fld_groups) { + $useIndex = false; // Show the groups the given users belong to // request more than needed to avoid not getting all rows that belong to one user $groupCount = count(User::getAllGroups()); @@ -104,8 +106,10 @@ class ApiQueryAllUsers extends ApiQueryBase { $this->addFieldsIf('u1.user_registration', $fld_registration); $this->addOption('ORDER BY', 'u1.user_name'); - $u1 = $this->getAliasedName('user', 'u1'); - $this->addOption('USE INDEX', array($u1 => 'user_name')); + if ($useIndex) { + $u1 = $this->getAliasedName('user', 'u1'); + $this->addOption('USE INDEX', array($u1 => 'user_name')); + } $res = $this->select(__METHOD__);