-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CX: Add new index to speed up query in "findByPublishedTitle" method
This patch adds a new index on the translation target title column of the "cx_translations" table, to speed up the query by reducing a full table scan, to scanning a few rows that match the given published title. Bug: T351999 Change-Id: Ib0b800966c47287e4e4d19ede043596ade26b4f8
- Loading branch information
Showing
10 changed files
with
359 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
246 changes: 246 additions & 0 deletions
246
sql/abstractSchemaChanges/patch-cx_translations-target-title-index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
{ | ||
"comment": "Add index to make finding of published translation by title faster (T351999)", | ||
"before": { | ||
"name": "cx_translations", | ||
"columns": [ | ||
{ | ||
"name": "translation_id", | ||
"comment": "translation id. Autogenerated.", | ||
"type": "integer", | ||
"options": { "autoincrement": true, "notnull": true } | ||
}, | ||
{ | ||
"name": "translation_source_title", | ||
"comment": "Source title of the translation", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 512 } | ||
}, | ||
{ | ||
"name": "translation_target_title", | ||
"comment": "Target title of the translation", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 512 } | ||
}, | ||
{ | ||
"name": "translation_source_language", | ||
"comment": "Source language. language code", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 36 } | ||
}, | ||
{ | ||
"name": "translation_target_language", | ||
"comment": "Target language. language code", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 36 } | ||
}, | ||
{ | ||
"name": "translation_source_revision_id", | ||
"comment": "Revision id of source article", | ||
"type": "integer", | ||
"options": { "notnull": false, "unsigned": true } | ||
}, | ||
{ | ||
"name": "translation_target_revision_id", | ||
"comment": "Revision id of published translation", | ||
"type": "integer", | ||
"options": { "notnull": false, "unsigned": true } | ||
}, | ||
{ | ||
"name": "translation_source_url", | ||
"comment": "source of the page as full canonical url -- https://www.mediawiki.org/wiki/Help:CxIsPage", | ||
"type": "blob", | ||
"options": { "notnull": true, "length": 65535 } | ||
}, | ||
{ | ||
"name": "translation_target_url", | ||
"comment": "link to the draft/published target", | ||
"type": "blob", | ||
"options": { "notnull": false, "length": 65535 } | ||
}, | ||
{ | ||
"name": "translation_status", | ||
"comment": "Status of translation - Draft or published status. There is no final status. A published translation can be draft again to update again", | ||
"type": "mwenum", | ||
"options": { | ||
"notnull": false, | ||
"CustomSchemaOptions": { | ||
"enum_values": [ "draft", "published", "deleted" ] | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "translation_start_timestamp", | ||
"comment": "Start date of this translation", | ||
"type": "mwtimestamp", | ||
"options": { "notnull": true } | ||
}, | ||
{ | ||
"name": "translation_last_updated_timestamp", | ||
"comment": "Last updated date of this translation", | ||
"type": "mwtimestamp", | ||
"options": { "notnull": true } | ||
}, | ||
{ | ||
"name": "translation_progress", | ||
"comment": "Progress of the translation - json dump", | ||
"type": "blob", | ||
"options": { "notnull": true, "length": 255 } | ||
}, | ||
{ | ||
"name": "translation_started_by", | ||
"comment": "Who started this translation? User id", | ||
"type": "integer", | ||
"options": { "notnull": false } | ||
}, | ||
{ | ||
"name": "translation_last_update_by", | ||
"comment": "Who did the last translation? It need not be the translator who started.", | ||
"type": "integer", | ||
"options": { "notnull": false } | ||
}, | ||
{ | ||
"name": "translation_cx_version", | ||
"comment": "Field to indicate which version of CX", | ||
"type": "mwtinyint", | ||
"options": { "notnull": false, "unsigned": true, "default": 1 } | ||
} | ||
], | ||
"indexes": [ | ||
{ | ||
"name": "cx_translation_ref", | ||
"columns": [ "translation_source_title", "translation_source_language", "translation_target_language", "translation_started_by" ], | ||
"unique": true | ||
}, | ||
{ | ||
"name": "cx_translation_languages", | ||
"columns": [ "translation_source_language", "translation_target_language", "translation_status" ], | ||
"unique": false | ||
} | ||
], | ||
"pk": [ "translation_id" ] | ||
}, | ||
"after": { | ||
"name": "cx_translations", | ||
"columns": [ | ||
{ | ||
"name": "translation_id", | ||
"comment": "translation id. Autogenerated.", | ||
"type": "integer", | ||
"options": { "autoincrement": true, "notnull": true } | ||
}, | ||
{ | ||
"name": "translation_source_title", | ||
"comment": "Source title of the translation", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 512 } | ||
}, | ||
{ | ||
"name": "translation_target_title", | ||
"comment": "Target title of the translation", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 512 } | ||
}, | ||
{ | ||
"name": "translation_source_language", | ||
"comment": "Source language. language code", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 36 } | ||
}, | ||
{ | ||
"name": "translation_target_language", | ||
"comment": "Target language. language code", | ||
"type": "binary", | ||
"options": { "notnull": true, "length": 36 } | ||
}, | ||
{ | ||
"name": "translation_source_revision_id", | ||
"comment": "Revision id of source article", | ||
"type": "integer", | ||
"options": { "notnull": false, "unsigned": true } | ||
}, | ||
{ | ||
"name": "translation_target_revision_id", | ||
"comment": "Revision id of published translation", | ||
"type": "integer", | ||
"options": { "notnull": false, "unsigned": true } | ||
}, | ||
{ | ||
"name": "translation_source_url", | ||
"comment": "source of the page as full canonical url -- https://www.mediawiki.org/wiki/Help:CxIsPage", | ||
"type": "blob", | ||
"options": { "notnull": true, "length": 65535 } | ||
}, | ||
{ | ||
"name": "translation_target_url", | ||
"comment": "link to the draft/published target", | ||
"type": "blob", | ||
"options": { "notnull": false, "length": 65535 } | ||
}, | ||
{ | ||
"name": "translation_status", | ||
"comment": "Status of translation - Draft or published status. There is no final status. A published translation can be draft again to update again", | ||
"type": "mwenum", | ||
"options": { | ||
"notnull": false, | ||
"CustomSchemaOptions": { | ||
"enum_values": [ "draft", "published", "deleted" ] | ||
} | ||
} | ||
}, | ||
{ | ||
"name": "translation_start_timestamp", | ||
"comment": "Start date of this translation", | ||
"type": "mwtimestamp", | ||
"options": { "notnull": true } | ||
}, | ||
{ | ||
"name": "translation_last_updated_timestamp", | ||
"comment": "Last updated date of this translation", | ||
"type": "mwtimestamp", | ||
"options": { "notnull": true } | ||
}, | ||
{ | ||
"name": "translation_progress", | ||
"comment": "Progress of the translation - json dump", | ||
"type": "blob", | ||
"options": { "notnull": true, "length": 255 } | ||
}, | ||
{ | ||
"name": "translation_started_by", | ||
"comment": "Who started this translation? User id", | ||
"type": "integer", | ||
"options": { "notnull": false } | ||
}, | ||
{ | ||
"name": "translation_last_update_by", | ||
"comment": "Who did the last translation? It need not be the translator who started.", | ||
"type": "integer", | ||
"options": { "notnull": false } | ||
}, | ||
{ | ||
"name": "translation_cx_version", | ||
"comment": "Field to indicate which version of CX", | ||
"type": "mwtinyint", | ||
"options": { "notnull": false, "unsigned": true, "default": 1 } | ||
} | ||
], | ||
"indexes": [ | ||
{ | ||
"name": "cx_translation_ref", | ||
"columns": [ "translation_source_title", "translation_source_language", "translation_target_language", "translation_started_by" ], | ||
"unique": true | ||
}, | ||
{ | ||
"name": "cx_translation_languages", | ||
"columns": [ "translation_source_language", "translation_target_language", "translation_status" ], | ||
"unique": false | ||
}, | ||
{ | ||
"name": "cx_translation_target_title", | ||
"columns": [ "translation_target_title" ], | ||
"unique": false | ||
} | ||
], | ||
"pk": [ "translation_id" ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. | ||
-- Source: extensions/ContentTranslation/sql/abstractSchemaChanges/patch-cx_translations-target-title-index.json | ||
-- Do not modify this file directly. | ||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes | ||
CREATE INDEX cx_translation_target_title ON /*_*/cx_translations (translation_target_title); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. | ||
-- Source: extensions/ContentTranslation/sql/abstractSchemaChanges/patch-cx_translations-target-title-index.json | ||
-- Do not modify this file directly. | ||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes | ||
CREATE INDEX cx_translation_target_title ON cx_translations (translation_target_title); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
-- This file is automatically generated using maintenance/generateSchemaChangeSql.php. | ||
-- Source: extensions/ContentTranslation/sql/abstractSchemaChanges/patch-cx_translations-target-title-index.json | ||
-- Do not modify this file directly. | ||
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes | ||
CREATE TEMPORARY TABLE /*_*/__temp__cx_translations AS | ||
SELECT | ||
translation_id, | ||
translation_source_title, | ||
translation_target_title, | ||
translation_source_language, | ||
translation_target_language, | ||
translation_source_revision_id, | ||
translation_target_revision_id, | ||
translation_source_url, | ||
translation_target_url, | ||
translation_status, | ||
translation_start_timestamp, | ||
translation_last_updated_timestamp, | ||
translation_progress, | ||
translation_started_by, | ||
translation_last_update_by, | ||
translation_cx_version | ||
FROM /*_*/cx_translations; | ||
DROP TABLE /*_*/cx_translations; | ||
|
||
|
||
CREATE TABLE /*_*/cx_translations ( | ||
translation_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
translation_source_title BLOB NOT NULL, | ||
translation_target_title BLOB NOT NULL, | ||
translation_source_language BLOB NOT NULL, | ||
translation_target_language BLOB NOT NULL, | ||
translation_source_revision_id INTEGER UNSIGNED DEFAULT NULL, | ||
translation_target_revision_id INTEGER UNSIGNED DEFAULT NULL, | ||
translation_source_url BLOB NOT NULL, | ||
translation_target_url BLOB DEFAULT NULL, | ||
translation_status TEXT DEFAULT NULL, | ||
translation_start_timestamp BLOB NOT NULL, | ||
translation_last_updated_timestamp BLOB NOT NULL, | ||
translation_progress BLOB NOT NULL, | ||
translation_started_by INTEGER DEFAULT NULL, | ||
translation_last_update_by INTEGER DEFAULT NULL, | ||
translation_cx_version SMALLINT UNSIGNED DEFAULT 1 | ||
); | ||
INSERT INTO /*_*/cx_translations ( | ||
translation_id, translation_source_title, | ||
translation_target_title, translation_source_language, | ||
translation_target_language, translation_source_revision_id, | ||
translation_target_revision_id, | ||
translation_source_url, translation_target_url, | ||
translation_status, translation_start_timestamp, | ||
translation_last_updated_timestamp, | ||
translation_progress, translation_started_by, | ||
translation_last_update_by, translation_cx_version | ||
) | ||
SELECT | ||
translation_id, | ||
translation_source_title, | ||
translation_target_title, | ||
translation_source_language, | ||
translation_target_language, | ||
translation_source_revision_id, | ||
translation_target_revision_id, | ||
translation_source_url, | ||
translation_target_url, | ||
translation_status, | ||
translation_start_timestamp, | ||
translation_last_updated_timestamp, | ||
translation_progress, | ||
translation_started_by, | ||
translation_last_update_by, | ||
translation_cx_version | ||
FROM | ||
/*_*/__temp__cx_translations; | ||
DROP TABLE /*_*/__temp__cx_translations; | ||
|
||
CREATE UNIQUE INDEX cx_translation_ref ON /*_*/cx_translations ( | ||
translation_source_title, translation_source_language, | ||
translation_target_language, translation_started_by | ||
); | ||
|
||
CREATE INDEX cx_translation_languages ON /*_*/cx_translations ( | ||
translation_source_language, translation_target_language, | ||
translation_status | ||
); | ||
|
||
CREATE INDEX cx_translation_target_title ON /*_*/cx_translations (translation_target_title); |
Oops, something went wrong.