Schema: Drop iwl_prefix_from_title from iwlinks

After exhuastive research, we concluded that iwl_prefix_from_title is
not used and in case it's actually used, other indexes provide enough
cardinality.

This table is about to grow quite large in Commons, let's avoid making
it bigger than it needs to be.

Bug: T343131
Change-Id: I89e40dff384291968d2465e4109a3d212ae2f8c7
This commit is contained in:
Amir Sarabadani 2024-02-05 14:35:04 +01:00
parent c16701b8d0
commit f0bfc3d433
11 changed files with 117 additions and 11 deletions

View file

@ -172,6 +172,7 @@ class MysqlUpdater extends DatabaseUpdater {
[ 'dropIndex', 'categorylinks', 'cl_collation_ext', 'patch-drop-cl_collation_ext.sql' ],
[ 'runMaintenance', PopulateUserIsTemp::class, 'maintenance/populateUserIsTemp.php' ],
[ 'dropIndex', 'sites', 'site_type', 'patch-sites-drop_indexes.sql' ],
[ 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-drop-iwl_prefix_from_title.sql' ],
];
}

View file

@ -472,6 +472,7 @@ class PostgresUpdater extends DatabaseUpdater {
[ 'dropIndex', 'categorylinks', 'cl_collation_ext', 'patch-drop-cl_collation_ext.sql' ],
[ 'runMaintenance', PopulateUserIsTemp::class, 'maintenance/populateUserIsTemp.php' ],
[ 'dropIndex', 'sites', 'site_type', 'patch-sites-drop_indexes.sql' ],
[ 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-drop-iwl_prefix_from_title.sql' ],
];
}

View file

@ -154,6 +154,7 @@ class SqliteUpdater extends DatabaseUpdater {
[ 'dropIndex', 'categorylinks', 'cl_collation_ext', 'patch-drop-cl_collation_ext.sql' ],
[ 'runMaintenance', PopulateUserIsTemp::class, 'maintenance/populateUserIsTemp.php' ],
[ 'dropIndex', 'sites', 'site_type', 'patch-sites-drop_indexes.sql' ],
[ 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-drop-iwl_prefix_from_title.sql' ],
];
}

View file

@ -0,0 +1,75 @@
{
"comment": "Drop iwl_title field from iwl_prefix_from_title index",
"before": {
"name": "iwlinks",
"comment": "Track inline interwiki links",
"columns": [
{
"name": "iwl_from",
"comment": "page_id of the referring page",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "default": 0 }
},
{
"name": "iwl_prefix",
"type": "binary",
"comment": "Interwiki prefix code of the target",
"options": { "notnull": true, "length": 32, "default": "" }
},
{
"name": "iwl_title",
"type": "binary",
"comment": "Title of the target, including namespace",
"options": { "notnull": true, "length": 255, "default": "" }
}
],
"indexes": [
{
"name": "iwl_prefix_title_from",
"columns": [ "iwl_prefix", "iwl_title", "iwl_from" ],
"comment": "Index for ApiQueryIWBacklinks",
"unique": false
},
{
"name": "iwl_prefix_from_title",
"columns": [ "iwl_prefix", "iwl_from", "iwl_title" ],
"comment": "Index for ApiQueryIWLinks",
"unique": false
}
],
"pk": [ "iwl_from", "iwl_prefix", "iwl_title" ]
},
"after": {
"name": "iwlinks",
"comment": "Track inline interwiki links",
"columns": [
{
"name": "iwl_from",
"comment": "page_id of the referring page",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "default": 0 }
},
{
"name": "iwl_prefix",
"type": "binary",
"comment": "Interwiki prefix code of the target",
"options": { "notnull": true, "length": 32, "default": "" }
},
{
"name": "iwl_title",
"type": "binary",
"comment": "Title of the target, including namespace",
"options": { "notnull": true, "length": 255, "default": "" }
}
],
"indexes": [
{
"name": "iwl_prefix_title_from",
"columns": [ "iwl_prefix", "iwl_title", "iwl_from" ],
"comment": "Index for ApiQueryIWBacklinks",
"unique": false
}
],
"pk": [ "iwl_from", "iwl_prefix", "iwl_title" ]
}
}

View file

@ -0,0 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-iwlinks-drop-iwl_prefix_from_title.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX iwl_prefix_from_title ON /*_*/iwlinks;

View file

@ -0,0 +1,5 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-iwlinks-drop-iwl_prefix_from_title.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX iwl_prefix_from_title;

View file

@ -238,8 +238,6 @@ CREATE TABLE iwlinks (
CREATE INDEX iwl_prefix_title_from ON iwlinks (iwl_prefix, iwl_title, iwl_from);
CREATE INDEX iwl_prefix_from_title ON iwlinks (iwl_prefix, iwl_from, iwl_title);
CREATE TABLE category (
cat_id SERIAL NOT NULL,

View file

@ -0,0 +1,29 @@
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: maintenance/abstractSchemaChanges/patch-iwlinks-drop-iwl_prefix_from_title.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__iwlinks AS
SELECT
iwl_from,
iwl_prefix,
iwl_title
FROM /*_*/iwlinks;
DROP TABLE /*_*/iwlinks;
CREATE TABLE /*_*/iwlinks (
iwl_from INTEGER UNSIGNED DEFAULT 0 NOT NULL,
iwl_prefix BLOB DEFAULT '' NOT NULL,
iwl_title BLOB DEFAULT '' NOT NULL,
PRIMARY KEY(iwl_from, iwl_prefix, iwl_title)
);
INSERT INTO /*_*/iwlinks (iwl_from, iwl_prefix, iwl_title)
SELECT
iwl_from,
iwl_prefix,
iwl_title
FROM
/*_*/__temp__iwlinks;
DROP TABLE /*_*/__temp__iwlinks;
CREATE INDEX iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);

View file

@ -231,8 +231,6 @@ CREATE TABLE /*_*/iwlinks (
CREATE INDEX iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
CREATE INDEX iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);
CREATE TABLE /*_*/category (
cat_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,

View file

@ -212,7 +212,6 @@ CREATE TABLE /*_*/iwlinks (
iwl_prefix VARBINARY(32) DEFAULT '' NOT NULL,
iwl_title VARBINARY(255) DEFAULT '' NOT NULL,
INDEX iwl_prefix_title_from (iwl_prefix, iwl_title, iwl_from),
INDEX iwl_prefix_from_title (iwl_prefix, iwl_from, iwl_title),
PRIMARY KEY(iwl_from, iwl_prefix, iwl_title)
) /*$wgDBTableOptions*/;

View file

@ -698,12 +698,6 @@
"columns": [ "iwl_prefix", "iwl_title", "iwl_from" ],
"comment": "Index for ApiQueryIWBacklinks",
"unique": false
},
{
"name": "iwl_prefix_from_title",
"columns": [ "iwl_prefix", "iwl_from", "iwl_title" ],
"comment": "Index for ApiQueryIWLinks",
"unique": false
}
],
"pk": [ "iwl_from", "iwl_prefix", "iwl_title" ]