From 640a6d311e91ccdc9bde1388f6e9840f332006c7 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 19 Jan 2009 15:33:22 +0000 Subject: [PATCH] Recommit r45821: (bug 16645) Making the pl_namespace, tl_namespace and il_to indices UNIQUE, just like their differently-ordered counterparts. This helps MySQL optimize stuff (see bug) --- maintenance/archives/patch-pl-tl-il-unique.sql | 11 +++++++++++ maintenance/tables.sql | 6 +++--- maintenance/updaters.inc | 12 ++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 maintenance/archives/patch-pl-tl-il-unique.sql diff --git a/maintenance/archives/patch-pl-tl-il-unique.sql b/maintenance/archives/patch-pl-tl-il-unique.sql new file mode 100644 index 0000000000..186a203669 --- /dev/null +++ b/maintenance/archives/patch-pl-tl-il-unique.sql @@ -0,0 +1,11 @@ +-- +-- patch-pl-tl-il-unique-index.sql +-- +-- Make reorderings of UNIQUE indices UNIQUE as well + +DROP INDEX /*i*/pl_namespace ON /*_*/pagelinks; +CREATE UNIQUE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace, pl_title, pl_from); +DROP INDEX /*i*/tl_namespace ON /*_*/templatelinks; +CREATE UNIQUE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace, tl_title, tl_from); +DROP INDEX /*i*/il_to ON /*_*/imagelinks; +CREATE UNIQUE INDEX /*i*/il_to ON /*_*/imagelinks (il_to, il_from); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index ba7ad96506..f643d0874e 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -408,7 +408,7 @@ CREATE TABLE /*_*/pagelinks ( ) /*$wgDBTableOptions*/; CREATE UNIQUE INDEX /*i*/pl_from ON /*_*/pagelinks (pl_from,pl_namespace,pl_title); -CREATE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from); +CREATE UNIQUE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from); -- @@ -427,7 +427,7 @@ CREATE TABLE /*_*/templatelinks ( ) /*$wgDBTableOptions*/; CREATE UNIQUE INDEX /*i*/tl_from ON /*_*/templatelinks (tl_from,tl_namespace,tl_title); -CREATE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from); +CREATE UNIQUE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from); -- @@ -446,7 +446,7 @@ CREATE TABLE /*_*/imagelinks ( ) /*$wgDBTableOptions*/; CREATE UNIQUE INDEX /*i*/il_from ON /*_*/imagelinks (il_from,il_to); -CREATE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from); +CREATE UNIQUE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from); -- diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index dade790b4e..cbdcbc87f3 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -149,6 +149,7 @@ $wgUpdates = array( array( 'add_field', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ), array( 'do_active_users_init' ), array( 'add_field', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ), + array( 'do_unique_pl_tl_il' ), ), 'sqlite' => array( @@ -1265,6 +1266,17 @@ function sqlite_initial_indexes() { echo "done\n"; } +function do_unique_pl_tl_il() { + global $wgDatabase; + $info = $wgDatabase->indexInfo( 'pagelinks', 'pl_namespace' ); + if( !$info->Non_unique ) { + echo "...pl_namespace, tl_namespace, il_to indices are already UNIQUE.\n"; + } else { + echo "Making pl_namespace, tl_namespace and il_to indices UNIQUE... "; + dbsource( archive( 'patch-pl-tl-il-unique.sql' ), $wgDatabase ); + echo "ok\n"; + } +} /*********************************************************************** * Start PG crap -- 2.20.1