btongminh@svn.wikimedia.org schreef:
Revision: 37050 Author: btongminh Date: 2008-07-04 13:36:21 +0000 (Fri, 04 Jul 2008)
Log Message:
Force index; Use straight_join
Modified Paths:
trunk/extensions/GlobalUsage/GlobalUsageDaemon.php
Modified: trunk/extensions/GlobalUsage/GlobalUsageDaemon.php
--- trunk/extensions/GlobalUsage/GlobalUsageDaemon.php 2008-07-04 13:04:03 UTC (rev 37049) +++ trunk/extensions/GlobalUsage/GlobalUsageDaemon.php 2008-07-04 13:36:21 UTC (rev 37050) @@ -77,11 +77,15 @@ do { $loopStart = microtime(true);
$sql = 'SELECT '.
$sql =
// Join order is important for sorting
'SELECT STRAIGHT_JOIN '. 'page_id, page_namespace, page_title, il_to, img_name IS NOT NULL AS is_local '. 'FROM '.$dbr->tableName('imagelinks').' '.
// MySQL will choose the il_to index from il_to > 'O'
// TODO: Doesn't work on the Toolserver
'FORCE INDEX(il_from) '. 'LEFT JOIN '.$dbr->tableName('image').' ON il_to = img_name '.
// Note the following JOIN should be after the LEFT JOIN 'JOIN '.$dbr->tableName('page').' ON page_id = il_from '. 'WHERE il_from >= '.$prevPage.' AND il_to > '.$dbr->addQuotes($prevImage). 'ORDER BY il_from, il_to ';
Holy hell... can't this extension use the Database class to clear up *some* of this mess? AFAIK, STRAIGHT_JOIN is a MySQL extension and will therefore break on other database engines.
Roan Kattouw (Catrope)