Page MenuHomePhabricator

Make page.page_namespace unsigned
Open, Needs TriagePublic

Description

Seen in T268673: maintenance/rebuildtextindex.php may fail with WikiPage.php: Invalid or virtual namespace -1 given

While for some other tables (links etc, maybe?) there may be a need for the _namespace field to allow < 0, the page table has no reason to do so.

Event Timeline

Reedy moved this task from Unsorted to Change on the Schema-change board.

Does this has performance impact on joins with this field if the datatypes are not the same?

Diesel_kapasule changed the task status from Open to In Progress.Apr 26 2022, 10:12 AM
Diesel_kapasule claimed this task.

Change 786288 had a related patch set uploaded (by Diesel kapasule; author: Diesel kapasule):

[mediawiki/core@master] Schema::Updating page_namespace field to unsigned

https://gerrit.wikimedia.org/r/786288

Does this has performance impact on joins with this field if the datatypes are not the same?

I think that’s a legitimate concern; I tried the alter locally, and the EXPLAIN for a randomly cobbled together query changed:

before
mysql> EXPLAIN SELECT page_id FROM page JOIN logging ON log_namespace = page_namespace AND log_title = page_title WHERE log_type = 'delete';
+----+-------------+---------+------------+--------+---------------------------------------------+-----------------+---------+-----------------------------------------------------+------+----------+-----------------------+
| id | select_type | table   | partitions | type   | possible_keys                               | key             | key_len | ref                                                 | rows | filtered | Extra                 |
+----+-------------+---------+------------+--------+---------------------------------------------+-----------------+---------+-----------------------------------------------------+------+----------+-----------------------+
|  1 | SIMPLE      | logging | NULL       | ref    | log_type_action,log_type_time,log_page_time | log_type_action | 34      | const                                               |  162 |   100.00 | Using index condition |
|  1 | SIMPLE      | page    | NULL       | eq_ref | page_name_title                             | page_name_title | 261     | wiki1.logging.log_namespace,wiki1.logging.log_title |    1 |   100.00 | Using index           |
+----+-------------+---------+------------+--------+---------------------------------------------+-----------------+---------+-----------------------------------------------------+------+----------+-----------------------+
after
+----+-------------+---------+------------+--------+---------------------------------------------+-----------------+---------+-----------------------------------------------------+------+----------+--------------------------+
| id | select_type | table   | partitions | type   | possible_keys                               | key             | key_len | ref                                                 | rows | filtered | Extra                    |
+----+-------------+---------+------------+--------+---------------------------------------------+-----------------+---------+-----------------------------------------------------+------+----------+--------------------------+
|  1 | SIMPLE      | logging | NULL       | ref    | log_type_action,log_type_time,log_page_time | log_type_action | 34      | const                                               |  162 |   100.00 | Using index condition    |
|  1 | SIMPLE      | page    | NULL       | eq_ref | page_name_title                             | page_name_title | 261     | wiki1.logging.log_namespace,wiki1.logging.log_title |    1 |   100.00 | Using where; Using index |
+----+-------------+---------+------------+--------+---------------------------------------------+-----------------+---------+-----------------------------------------------------+------+----------+--------------------------+
2 rows in set, 1 warning (0.00 sec)

That “using where” under extra is worrying.

Pppery changed the task status from In Progress to Open.Tue, Apr 2, 11:45 PM
Pppery edited projects, added Patch-Needs-Improvement; removed Patch-For-Review.