From: Aaron Schulz Date: Mon, 11 Apr 2016 21:01:43 +0000 (-0700) Subject: Remove redundant UNIQUE from rev_page_id X-Git-Tag: 1.31.0-rc.0~5896^2 X-Git-Url: http://git.cyclocoop.org/%24dirpuce/puce%24spip_lang_rtl.gif?a=commitdiff_plain;h=af58998190d5a3ac3079f015796bf167466b7781;p=lhc%2Fweb%2Fwiklou.git Remove redundant UNIQUE from rev_page_id The PRIMARY KEY is rev_id, so this is a waste and makes the index slower to maintain (e.g. no change buffering). Bug: T142725 Change-Id: I63f817656ff5e62aa27caf607d70353cc99eb349 --- diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 719b66aafb..6989969187 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -287,6 +287,7 @@ class MysqlUpdater extends DatabaseUpdater { // 1.28 [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp', 'patch-add-rc_name_type_patrolled_timestamp_index.sql' ], + [ 'doRevisionPageRevIndexNonUnique' ] ]; } @@ -1101,4 +1102,24 @@ class MysqlUpdater extends DatabaseUpdater { 'Making user_id unsigned int' ); } + + protected function doRevisionPageRevIndexNonUnique() { + if ( !$this->doTable( 'revision' ) ) { + return true; + } elseif ( !$this->db->indexExists( 'revision', 'rev_page_id' ) ) { + $this->output( "...rev_page_id index not found on revision.\n" ); + return true; + } + + if ( !$this->db->indexUnique( 'revision', 'rev_page_id' ) ) { + $this->output( "...rev_page_id index already non-unique.\n" ); + return true; + } + + return $this->applyPatch( + 'patch-revision-page-rev-index-nonunique.sql', + false, + 'Making rev_page_id index non-unique' + ); + } } diff --git a/maintenance/archives/patch-revision-page-rev-index-nonunique.sql b/maintenance/archives/patch-revision-page-rev-index-nonunique.sql new file mode 100644 index 0000000000..dbb03257e1 --- /dev/null +++ b/maintenance/archives/patch-revision-page-rev-index-nonunique.sql @@ -0,0 +1,5 @@ +-- Makes rev_page_id index non-unique +ALTER TABLE /*_*/revision +DROP INDEX /*i*/rev_page_id; + +CREATE INDEX /*i*/rev_page_id ON /*_*/revision (rev_page, rev_id); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 40506bf3bd..b5c14e30f4 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -369,7 +369,7 @@ CREATE TABLE /*_*/revision ( ) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=1024; -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit -CREATE UNIQUE INDEX /*i*/rev_page_id ON /*_*/revision (rev_page, rev_id); +CREATE INDEX /*i*/rev_page_id ON /*_*/revision (rev_page, rev_id); CREATE INDEX /*i*/rev_timestamp ON /*_*/revision (rev_timestamp); CREATE INDEX /*i*/page_timestamp ON /*_*/revision (rev_page,rev_timestamp); CREATE INDEX /*i*/user_timestamp ON /*_*/revision (rev_user,rev_timestamp);