Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
alter table menu_router add index tab_root (tab_root);
Before:
mysql> explain SELECT * FROM menu_router WHERE tab_root = 'profile' ORDER BY weight, title;
+----+-------------+-------------+------+---------------+------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+---------------+------+---------+------+------+-----------------------------+
| 1 | SIMPLE | menu_router | ALL | NULL | NULL | NULL | NULL | 481 | Using where; Using filesort |
+----+-------------+-------------+------+---------------+------+---------+------+------+-----------------------------+
After:
mysql> explain SELECT * FROM menu_router WHERE tab_root = 'profile' ORDER BY weight, title;
+----+-------------+-------------+------+---------------+----------+---------+-------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+---------------+----------+---------+-------+------+-----------------------------+
| 1 | SIMPLE | menu_router | ref | tab_root | tab_root | 767 | const | 1 | Using where; Using filesort |
+----+-------------+-------------+------+---------------+----------+---------+-------+------+-----------------------------+
Comment | File | Size | Author |
---|---|---|---|
#35 | tab_root.patch | 699 bytes | catch |
#30 | tab_root-371458-30-D6.patch | 901 bytes | febbraro |
#29 | tab_root.patch | 1.02 KB | catch |
#26 | 371458-tab_root.patch | 1.02 KB | smk-ka |
#22 | menu_router_index.patch | 992 bytes | Gerhard Killesreiter |
Comments
Comment #1
robertDouglass CreditAttribution: robertDouglass commentedsubscribe
Comment #2
robertDouglass CreditAttribution: robertDouglass commentedComment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedBumping to D7.
Comment #4
David StraussThe index should be on (tab_root, weight, title). This will eliminate the filesort, as well.
Comment #5
stormsweeper CreditAttribution: stormsweeper commented@Damien
Still a big issue on 6.x sites - menu_local_tasks calls a query on every page that for me took 500ms or so before the index, less than 5 after.
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commented@stormsweeper: we fix issues in the current development version (Drupal 7), before backporting them.
Comment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedComment #9
Gerhard Killesreiter CreditAttribution: Gerhard Killesreiter commentedI believe the failed test is because of:
alter table menu_router add index tab_root_weight_title (tab_root, weight, title);
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
tab_root and title are only varchar(255) but that may be more than 1000 bytes for utf-8, I think.
Comment #10
Gerhard Killesreiter CreditAttribution: Gerhard Killesreiter commentedIndeed, if I change tab_router to be varchar(64) (which really should be enough), I get:
+----+-------------+-------------+------+-----------------------+-----------------------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+------+-----------------------+-----------------------+---------+-------+------+-------------+
| 1 | SIMPLE | menu_router | ref | tab_root_weight_title | tab_root_weight_title | 195 | const | 1 | Using where |
+----+-------------+-------------+------+-----------------------+-----------------------+---------+-------+------+-------------+
excellent.
Comment #11
killes@www.drop.org CreditAttribution: killes@www.drop.org commented19:44 < chx> killes: you must not change tab_root without changing path and menu_link router_path
Comment #12
killes@www.drop.org CreditAttribution: killes@www.drop.org commented19:56 < chx> killes: paths => 128, title => 200.
Comment #13
FiReaNGeL CreditAttribution: FiReaNGeL commentedYou can specify the number of characters the index should use - you can use the first 64 or 128 out of a 255 characters field. I don't think limiting the length in the database is the right way to do it.
Comment #14
smk-ka CreditAttribution: smk-ka commentedRe-rolled with limited index length as FiReaNG3L suggested.
Comment #15
Damien Tournoud CreditAttribution: Damien Tournoud commentedI would rather limit the size of the title part. In any case, we need to validate that MySQL can do something with this partial index.
Comment #16
stormsweeper CreditAttribution: stormsweeper commentedHere's some explains from Postgres on a 6.x database, if it's helpful. No real difference between just the index on tab_root and the additional columns; the latter just gets used the same as if it were only on the single column.
Comment #17
smk-ka CreditAttribution: smk-ka commented@stormsweeper
The syntax of substr is
substr(string, from [, count])
, thus the index you created has no effect. Not sure, though, whether a correct index helps Postgres in any way.Comment #18
stormsweeper CreditAttribution: stormsweeper commented@smk-ka
Sorry, you're correct. You're right, though, it doesn't make much difference. Postgres doesn't seem to care for substring indexes in any case - you'll note that only the whole column index is uses for the order by.
Comment #20
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedThe previous patch failed because other patches increased the numbers in system.install.
Comment #22
Gerhard Killesreiter CreditAttribution: Gerhard Killesreiter commentedRenumbering again.
Comment #24
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedtrying again.
Comment #26
smk-ka CreditAttribution: smk-ka commentedBingo?
Comment #27
catchCan someone run the EXPLAIN on this patch? Then it should be rtbc.
Comment #29
catchRe-rolled for system_update conflict, here's the EXPLAIN I asked for, RTBC.
Before:
After:
Comment #30
febbraro CreditAttribution: febbraro commentedHere is a re-roll for D6, including the explain.
BEFORE:
AFTER:
Comment #31
webchickCommitted to HEAD.
Hm. I'm not sure if this means the 6.x patch needs to be re-rolled to *remove* the update hook I just committed. This is always very confusing. :\ I'll leave it RTBC and Gábor will know what to do.
Comment #32
Gábor HojtsyCommitted to Drupal 6 too. Moving back to 7.x to fix the update function. (Marking critical so it does not slip without being fixed before the release).
Comment #33
catchPatch.
Comment #34
robertDouglass CreditAttribution: robertDouglass commentedCatch, did you forget to upload a patch?
Comment #35
catchI did.
Comment #36
moshe weitzman CreditAttribution: moshe weitzman commentedIn addition to this patch, we need to document (if not already present) that sites should be on the very latest 6.x release before upgrading to 7. If they don't do that, they can miss an index like this one. I don't think we want to support upgrading from any 6.x release to 7.x. Thats too many use cases to test for core and for contrib.
Comment #37
catch@moshe - since we keep 6.x-7.x extra in, it should be technically possible to upgrade 6.0-7.x.
Personally I think we should only support versions of 6.x available during or after the first 7.x RC (then support everything after that) because the overhead for committing updates to both releases is very high at the moment, and there should be few schema changes to both versions past that point anyway, but that's not the consensus according to #278592: Sync 6.x extra updates with HEAD since I was apparently the only person on that issue with that view, and we'll need a new issue to change it.
Comment #38
Dries CreditAttribution: Dries commentedFeels a little bit odd, to me, but asking people to upgrade to the latest D6 version is probably the right thing to do anyway.
Comment #39
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.
Comment #40
moshe weitzman CreditAttribution: moshe weitzman commentedPerhaps we should put the index back in with a conditional index check? It is now possible as #360854: db_index_exists() missing, module updates cannot handle indexes properly was just committed. I still think we only have enough resources to test the upgrade path from one D6 release (the latest one).
Comment #41
catchIt's in 7 though, as http://api.drupal.org/api/function/system_update_6052/7
Comment #43
zirafi CreditAttribution: zirafi commentedHi,
I am seeing database upgrade errors on my site's update completion page and the same page also prompted go to Administration pages as well.
Update #6052
Failed: ALTER TABLE {menu_router} ADD INDEX tab_root_weight_title (tab_root(64), weight, title)
Update #6015
Failed: CREATE TABLE {cache_form} ( cid varchar(255) NOT NULL default '', data longblob, expire int NOT NULL default '0', created int NOT NULL default '0', headers text, serialized int(1) NOT NULL default '0', PRIMARY KEY (cid), INDEX expire (expire) ) /*!40100 DEFAULT CHARACTER SET UTF8 */
Update #6020
Failed: CREATE TABLE {menu_router} ( `path` VARCHAR(255) NOT NULL DEFAULT '', `load_functions` VARCHAR(255) NOT NULL DEFAULT '', `to_arg_functions` VARCHAR(255) NOT NULL DEFAULT '', `access_callback` VARCHAR(255) NOT NULL DEFAULT '', `access_arguments` TEXT DEFAULT NULL, `page_callback` VARCHAR(255) NOT NULL DEFAULT '', `page_arguments` TEXT DEFAULT NULL, `fit` INT NOT NULL DEFAULT 0, `number_parts` SMALLINT NOT NULL DEFAULT 0, `tab_parent` VARCHAR(255) NOT NULL DEFAULT '', `tab_root` VARCHAR(255) NOT NULL DEFAULT '', `title` VARCHAR(255) NOT NULL DEFAULT '', `title_callback` VARCHAR(255) NOT NULL DEFAULT '', `title_arguments` VARCHAR(255) NOT NULL DEFAULT '', `type` INT NOT NULL DEFAULT 0, `block_callback` VARCHAR(255) NOT NULL DEFAULT '', `description` TEXT NOT NULL, `position` VARCHAR(255) NOT NULL DEFAULT '', `weight` INT NOT NULL DEFAULT 0, `file` MEDIUMTEXT DEFAULT NULL, PRIMARY KEY (path), INDEX fit (fit), INDEX tab_parent (tab_parent) ) /*!40100 DEFAULT CHARACTER SET UTF8 */
Failed: CREATE TABLE {menu_links} ( `menu_name` VARCHAR(32) NOT NULL DEFAULT '', `mlid` INT unsigned NOT NULL auto_increment, `plid` INT unsigned NOT NULL DEFAULT 0, `link_path` VARCHAR(255) NOT NULL DEFAULT '', `router_path` VARCHAR(255) NOT NULL DEFAULT '', `link_title` VARCHAR(255) NOT NULL DEFAULT '', `options` TEXT DEFAULT NULL, `module` VARCHAR(255) NOT NULL DEFAULT 'system', `hidden` SMALLINT NOT NULL DEFAULT 0, `external` SMALLINT NOT NULL DEFAULT 0, `has_children` SMALLINT NOT NULL DEFAULT 0, `expanded` SMALLINT NOT NULL DEFAULT 0, `weight` INT NOT NULL DEFAULT 0, `depth` SMALLINT NOT NULL DEFAULT 0, `customized` SMALLINT NOT NULL DEFAULT 0, `p1` INT unsigned NOT NULL DEFAULT 0, `p2` INT unsigned NOT NULL DEFAULT 0, `p3` INT unsigned NOT NULL DEFAULT 0, `p4` INT unsigned NOT NULL DEFAULT 0, `p5` INT unsigned NOT NULL DEFAULT 0, `p6` INT unsigned NOT NULL DEFAULT 0, `p7` INT unsigned NOT NULL DEFAULT 0, `p8` INT unsigned NOT NULL DEFAULT 0, `p9` INT unsigned NOT NULL DEFAULT 0, `updated` SMALLINT NOT NULL DEFAULT 0, PRIMARY KEY (mlid), INDEX path_menu (link_path(128), menu_name), INDEX menu_plid_expand_child (menu_name, plid, expanded, has_children), INDEX menu_parents (menu_name, p1, p2, p3, p4, p5, p6, p7, p8, p9), INDEX router_path (router_path(128)) ) /*!40100 DEFAULT CHARACTER SET UTF8 */
Update #6043
ALTER TABLE {flood} ADD INDEX allow (event, hostname, timestamp)
ALTER TABLE {history} ADD INDEX nid (nid)
ALTER TABLE {blocks} CHANGE `theme` `theme` VARCHAR(64) NOT NULL DEFAULT '', ADD UNIQUE KEY tmd (theme, module, delta), ADD INDEX list (theme, status, region, weight, module)
ALTER TABLE {blocks_roles} ADD INDEX rid (rid)
ALTER TABLE {filters} DROP INDEX weight
Failed: ALTER TABLE {filters} ADD UNIQUE KEY fmd (format, module, delta)
ALTER TABLE {filters} ADD INDEX list (format, weight, module, delta)
ALTER TABLE {profile_values} CHANGE `uid` `uid` INT unsigned NOT NULL DEFAULT 0
Failed: ALTER TABLE {profile_values} ADD PRIMARY KEY (uid, fid)
ALTER TABLE {accesslog} ADD INDEX uid (uid)
Update #6052
Failed: ALTER TABLE {menu_router} ADD INDEX tab_root_weight_title (tab_root(64), weight, title)
Could you let me know whether applying the above patch should fix the above failures and also I could not find the link to download this patch.
thanks
~Paradesi
Comment #43.0
zirafi CreditAttribution: zirafi commentedadded code tags