Last modified: 2008-12-16 04:28:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 16632 - updateArticleCount.inc.php can be made significantly more efficient
updateArticleCount.inc.php can be made significantly more efficient
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Maintenance scripts (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: easy
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-13 19:52 UTC by Sean Colombo
Modified: 2008-12-16 04:28 UTC (History)
1 user (show)

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


Attachments

Description Sean Colombo 2008-12-13 19:52:37 UTC
The query in updateArticleCount.inc.php's makeSql() function can be made faster an less RAM-intensive.  It currently queries for a ton of rows, then counts the number of rows in the result.

The current query is:
return "SELECT DISTINCT page_namespace,page_title FROM $page,$pagelinks " .
			"WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
			"AND page_is_redirect = 0 AND page_len > 0";
but could be changed to:
return "SELECT COUNT(DISTINCT page_namespace,page_title) FROM $page,$pagelinks " .
			"WHERE pl_from=page_id and page_namespace IN ( $nsset ) " .
			"AND page_is_redirect = 0 AND page_len > 0";

The code in the count() function would have to be updated also.  Instead of
			$count = $this->dbr->numRows( $res );
			$this->dbr->freeResult( $res );
			return $count;
it could be changed to:
			$row = $this->dbr->fetchObject( $res );
			$this->dbr->freeResult( $res );
			return (int)$row->count;
Comment 1 Sean Colombo 2008-12-14 22:33:49 UTC
CORRECTION!!!

The query that it should be replaced with should be:
return "SELECT COUNT(DISTINCT page_namespace,page_title) as count FROM $page,$pagelinks" .
                        "WHERE pl_from=page_id and page_namespace IN ( $nsset )" .
                        "AND page_is_redirect = 0 AND page_len > 0";

The difference is the addition of " as count" in there.  Otherwise there will be an error on the line below where it has "return (int)$row->count;"
Comment 2 Ilmari Karonen 2008-12-16 04:28:32 UTC
Done in r44648.

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


Navigation
Links