mysql> explain SELECT filename FROM system WHERE name = 'cvs' AND type = 'module';
+----+-------------+--------+------+-------------------+---------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+-------------------+---------+---------+-------+------+-------------+
| 1 | SIMPLE | system | ref | modules,bootstrap | modules | 38 | const | 63 | Using where |
+----+-------------+--------+------+-------------------+---------+---------+-------+------+-------------+
1 row in set (0.00 sec)
mysql> alter table system add index name (name);
Query OK, 127 rows affected (0.06 sec)
Records: 127 Duplicates: 0 Warnings: 0
mysql> explain SELECT filename FROM system WHERE name = 'cvs' AND type = 'module';
+----+-------------+--------+------+------------------------+------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+------------------------+------+---------+-------+------+-------------+
| 1 | SIMPLE | system | ref | modules,bootstrap,name | name | 767 | const | 1 | Using where |
+----+-------------+--------+------+------------------------+------+---------+-------+------+-------------+
1 row in set (0.00 sec)
Comments
Comment #1
dave reidSee #215080: Performance: change {system}.type: alter table system modify column type VARCHAR(32); that should be backported to 6.x.
Comment #2
robertdouglass commentedSo wait? Gábor says he doesn't want to change the schema in D6. Perhaps this index is a good idea in addition to #215080: Performance: change {system}.type: alter table system modify column type VARCHAR(32);?
Comment #3
dave reidI posted the index backport (without the schema change in #215080: Performance: change {system}.type: alter table system modify column type VARCHAR(32);.
Comment #4
keith.smith commentedComment #5
david straussThe index ought to be on name and type, preferably in that order.
Setting to minor because this is a small, non-volatile table whose queries are mostly handled out of the query cache.
Comment #6
stormsweeper commentedThe indexes help Postgres performance greatly:
Note that I'm using the full column name in Postgres, as it supports them. The way Drupal currently implements partial text indexing also doesn't work, but I will file that as another issue.
Comment #7
andypostThis one already fixed in #215080: Performance: change {system}.type: alter table system modify column type VARCHAR(32); waiting for upgrade path
system_update_7018()Comment #7.0
andypostadded code tags so you can read WTF this says.