Last modified: 2012-11-11 11:32:06 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T29659, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27659 - USE INDEX is inserted in the wrong place when left joining in other tables
USE INDEX is inserted in the wrong place when left joining in other tables
Status: NEW
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.18.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-23 13:00 UTC by Sam Reed (reedy)
Modified: 2012-11-11 11:32 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Sam Reed (reedy) 2011-02-23 13:00:26 UTC
After r82659, the following query was created

SELECT user_name,MAX(user_id) AS user_id,MAX(user_editcount) AS edits,COUNT(ug_group) AS numgroups,MAX(ug_group) AS singlegroup,MIN(user_registration) AS creation,MAX(ipb_deleted) AS ipb_deleted FROM `mw_user` LEFT JOIN `mw_user_groups` ON ((user_id=ug_user)) LEFT JOIN `mw_ipblocks` ON ((user_id=ipb_user AND ipb_deleted=1 AND ipb_auto=0)) FORCE INDEX (user_name) WHERE (ipb_deleted IS NULL) GROUP BY user_name ORDER BY user_name LIMIT 51\G

It needs to be

SELECT user_name,MAX(user_id) AS user_id,MAX(user_editcount) AS edits,COUNT(ug_group) AS numgroups,MAX(ug_group) AS singlegroup,MIN(user_registration) AS creation,MAX(ipb_deleted) AS ipb_deleted FROM `mw_user` FORCE INDEX (user_name) LEFT JOIN `mw_user_groups` ON ((user_id=ug_user)) LEFT JOIN `mw_ipblocks` ON ((user_id=ipb_user AND ipb_deleted=1 AND ipb_auto=0))  WHERE (ipb_deleted IS NULL) GROUP BY user_name ORDER BY user_name LIMIT 51\G

http://svn.wikimedia.org/viewvc/mediawiki/branches/REL1_17/phase3/includes/specials/SpecialListusers.php?view=annotate

^ It seems in 1.17 (I broke the index inclusion in r79699) it's done a bit hackily...
Comment 1 Sam Reed (reedy) 2011-02-23 13:01:54 UTC
		if ( !empty( $conds ) ) {
			if ( is_array( $conds ) ) {
				$conds = $this->makeList( $conds, LIST_AND );
			}
			$sql = "SELECT $startOpts $vars $from $useIndex WHERE $conds $preLimitTail";
		} else {
			$sql = "SELECT $startOpts $vars $from $useIndex $preLimitTail";
		}

$from is only right when not LEFT JOIN'ing in tables
Comment 2 db [inactive,noenotif] 2012-11-11 11:32:06 UTC
Sounds like bug 22613

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links