* Changed the schema, put an index on img_major_mime and img_minor_mime
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 13 Sep 2005 16:33:50 +0000 (16:33 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 13 Sep 2005 16:33:50 +0000 (16:33 +0000)
maintenance/archives/patch-mimesearch-indexes.sql [new file with mode: 0644]
maintenance/tables.sql
maintenance/updaters.inc

diff --git a/maintenance/archives/patch-mimesearch-indexes.sql b/maintenance/archives/patch-mimesearch-indexes.sql
new file mode 100644 (file)
index 0000000..bd348c4
--- /dev/null
@@ -0,0 +1,22 @@
+-- Add indexes to the mime types in image for use on Special:MIMEsearch,
+-- changes a query like
+--
+-- SELECT img_name FROM image WHERE img_major_mime = "image" AND img_minor_mime = "svg";
+-- from:
+-- +-------+------+---------------+------+---------+------+------+-------------+
+-- | table | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+-- +-------+------+---------------+------+---------+------+------+-------------+
+-- | image | ALL  | NULL          | NULL |    NULL | NULL |  194 | Using where |
+-- +-------+------+---------------+------+---------+------+------+-------------+
+-- to:
+-- +-------+------+-------------------------------+----------------+---------+-------+------+-------------+
+-- | table | type | possible_keys                 | key            | key_len | ref   | rows | Extra       |
+-- +-------+------+-------------------------------+----------------+---------+-------+------+-------------+
+-- | image | ref  | img_major_mime,img_minor_mime | img_minor_mime |      32 | const |    4 | Using where |
+-- +-------+------+-------------------------------+----------------+---------+-------+------+-------------+
+
+ALTER TABLE /*$wgDBprefix*/image
+       ADD INDEX img_major_mime (img_major_mime);
+ALTER TABLE /*$wgDBprefix*/image
+       ADD INDEX img_minor_mime (img_minor_mime);
+
index 4f9a26f..27de265 100644 (file)
@@ -552,6 +552,10 @@ CREATE TABLE /*$wgDBprefix*/image (
   
   -- Used by Special:Imagelist for sort-by-size
   INDEX img_size (img_size),
+
+  -- Used by Special:MIMEsearch for searching
+  INDEX img_major_mime (img_major_mime),
+  INDEX img_minor_mime (img_minor_mime),
   
   -- Used by Special:Newimages and Special:Imagelist
   INDEX img_timestamp (img_timestamp)
@@ -559,7 +563,7 @@ CREATE TABLE /*$wgDBprefix*/image (
 ) TYPE=InnoDB;
 
 --
--- Previous revisions of uploaded files.
+-- Previous ervisions of uploaded files.
 -- Awkwardly, image rows have to be moved into
 -- this table at re-upload time.
 --
index 6ce2de6..757f38d 100644 (file)
@@ -157,6 +157,20 @@ function do_index_update() {
        return false;
 }
 
+function do_image_index_update() {
+       global $wgDatabase;
+       
+       $meta = $wgDatabase->fieldInfo( "image", "img_major_mime" );
+       if( $meta->multiple_key == 0 ) {
+               echo "Updating indexes to 20050912: ";
+               dbsource( archive("patch-mimesearch-indexes.sql") );
+               echo "ok\n";
+               return true;
+       }
+       echo "...indexes seem up to 20050912 standards\n";
+       return false;
+}
+
 function do_image_name_unique_update() {
        global $wgDatabase;
        if( $wgDatabase->indexExists( 'image', 'PRIMARY' ) ) {
@@ -689,6 +703,8 @@ function do_all_updates() {
        
        do_watchlist_null(); flush();
 
+       do_image_index_update(); flush();
+
        initialiseMessages(); flush();
 }