* (bug 13577) Optimize query in Special Unusedcategories & Special Mostlinkedcategori...
authorSam Reed <reedy@users.mediawiki.org>
Sun, 20 Nov 2011 14:49:07 +0000 (14:49 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sun, 20 Nov 2011 14:49:07 +0000 (14:49 +0000)
Patch by Nicolas Dumazet, updated in line with changed code

If unbounded it does a filesort. With a limit, it's a fine query

Marking as not expensive

includes/specials/SpecialMostlinkedcategories.php

index 6b36d5a..672462a 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 /**
- * A querypage to show categories ordered in descending order by the pages  in them
+ * A querypage to show categories ordered in descending order by the pages in them
  *
  * @ingroup SpecialPage
  */
@@ -35,16 +35,15 @@ class MostlinkedCategoriesPage extends QueryPage {
                parent::__construct( $name );
        }
 
-       function isExpensive() { return true; }
        function isSyndicated() { return false; }
 
        function getQueryInfo() {
                return array (
-                       'tables' => array ( 'categorylinks' ),
-                       'fields' => array ( 'cl_to AS title',
+                       'tables' => array ( 'category' ),
+                       'fields' => array ( 'cat_title AS title',
                                        NS_CATEGORY . ' AS namespace',
-                                       'COUNT(*) AS value' ),
-                       'options' => array ( 'GROUP BY' => 'cl_to' )
+                                       'cat_pages AS value' ),
+                       'options' => array ( 'ORDER BY' => 'cat_pages' )
                );
        }