stable

Clone or download

Read-only

feat: Add index on rank in artidoc table

When we retrieve artidoc section, we order them by rank. Until now, this column didn't have any index, forcing MySQL to use a "filesort". This can be see with the following query: ``` EXPLAIN SELECT * FROM plugin_artidoc_document WHERE item_id = 380 ORDER BY `rank` ``` With only a primary index (item_id, artifact_id), MySQL will use the index to retrieve item_id, but have some extra work to sort the result. ``` [ { "id": 1, "select_type": "SIMPLE", "table": "plugin_artidoc_document", "partitions": null, "type": "ref", "possible_keys": "PRIMARY", "key": "PRIMARY", "key_len": "4", "ref": "const", "rows": 7, "filtered": 100, "Extra": "Using filesort" } ] ``` If we add an index (item_id, rank), then MySQL will use this index retrieve and sort data: ``` [ { "id": 1, "select_type": "SIMPLE", "table": "plugin_artidoc_document", "partitions": null, "type": "ref", "possible_keys": "PRIMARY,idx_rank", "key": "idx_rank", "key_len": "4", "ref": "const", "rows": 7, "filtered": 100, "Extra": "Using index" } ] ``` No functional changes. Part of story #37542: display a read only Document Change-Id: I471f6df231944aee7473546913f730b4c771c1ee

Modified Files

Name
M plugins/artidoc/db/install.sql +2 −1 Go to diff View file
M plugins/artidoc/db/mysql/2024/202404041430_add_artidoc_document_table.php +1 −1 Go to diff View file
A plugins/artidoc/db/mysql/2024/202404230904_add_index_on_rank.php +41 −0 Go to diff View file