From 0bdf8e9376c4475d24567d4d1f22014fd446a9dc Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Wed, 29 Aug 2007 02:33:13 +0000 Subject: [PATCH] * Add an index to (rev_page,rev_user,rev_timestamp) for use in "All edits by a user to this page". Also potentially useful for "edits to a page grouped by user". (Would "edits by a user grouped by page" be more useful instead?) See bug 10788. Code to implement that feature will follow at some point when the index has actually been applied to Wikimedia servers, probably shortly after I get annoyed at its nonexistence again when looking for an old edit of mine. * Bowlderism --- includes/Article.php | 4 ++-- .../archives/patch-revision-user-page-index.sql | 5 +++++ maintenance/tables.sql | 3 ++- maintenance/updaters.inc | 15 ++++++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 maintenance/archives/patch-revision-user-page-index.sql diff --git a/includes/Article.php b/includes/Article.php index 5bb5915eb3..040a905868 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2461,8 +2461,8 @@ class Article { * * @param Revision $rev * - * @todo This is a shitty interface function. Kill it and replace the - * other shitty functions like editUpdates and such so it's not needed + * @todo This is a lousy interface function. Kill it and replace the + * other cruddy functions like editUpdates and such so it's not needed * anymore. */ function createUpdates( $rev ) { diff --git a/maintenance/archives/patch-revision-user-page-index.sql b/maintenance/archives/patch-revision-user-page-index.sql new file mode 100644 index 0000000000..9058e4e9fc --- /dev/null +++ b/maintenance/archives/patch-revision-user-page-index.sql @@ -0,0 +1,5 @@ +-- New index on revision table to allow searches for all edits by a given user +-- to a given page. Added 2007-08-28 + +ALTER TABLE /*$wgDBprefix*/revision + ADD INDEX page_user_timestamp (rev_page,rev_user,rev_timestamp); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 7477e5bea0..d23dc48316 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -282,7 +282,8 @@ CREATE TABLE /*$wgDBprefix*/revision ( INDEX rev_timestamp (rev_timestamp), INDEX page_timestamp (rev_page,rev_timestamp), INDEX user_timestamp (rev_user,rev_timestamp), - INDEX usertext_timestamp (rev_user_text,rev_timestamp) + INDEX usertext_timestamp (rev_user_text,rev_timestamp), + INDEX page_user_timestamp (rev_page,rev_user,rev_timestamp) ) /*$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 diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index e8fd2061f2..dfe970419d 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -1032,6 +1032,8 @@ function do_all_updates( $shared = false, $purge = true ) { do_oldimage_user_index(); flush (); + do_revision_page_user_index(); flush (); + echo "Deleting old default messages (this may take a long time!)..."; flush(); deleteDefaultMessages(); echo "Done\n"; flush(); @@ -1130,6 +1132,17 @@ function do_restrictions_update() { } +function do_revision_page_user_index() { + global $wgDatabase; + if( $wgDatabase->indexExists( 'revision', 'page_user_timestamp' ) ) { + echo "...page,user,timestamp key on revision already exists.\n"; + } else { + echo "Adding page,user,timestamp key on revision table... "; + dbsource( archive("patch-revision-user-page-index.sql"), $wgDatabase ); + echo "ok\n"; + } +} + function pg_describe_table($table) { @@ -1529,4 +1542,4 @@ function do_postgres_updates() { } return; -} \ No newline at end of file +} -- 2.20.1