--- /dev/null
+-- 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);
+
-- 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)
) 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.
--
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' ) ) {
do_watchlist_null(); flush();
+ do_image_index_update(); flush();
+
initialiseMessages(); flush();
}