We have ~60,000 records in our redirect table and the queries are not using an index and are generally running at 200+ ms per query (one on every page).
The query is generally using a condition on the source and language tables so an index on this would improve performance no end.
I've attached a patch, the only problem with which is the length of time it takes to create the index on large tables.
mysql> SELECT redirect.rid AS rid FROM redirect redirect WHERE ( (source LIKE 'home' ESCAPE '\\') OR (source = '') )AND (language IN ('en', 'und'));
Empty set (0.20 sec)
mysql> create index source_language on redirect (source,language);
Query OK, 60283 rows affected (26.76 sec)
Records: 60283 Duplicates: 0 Warnings: 0
mysql> SELECT redirect.rid AS rid FROM redirect redirect WHERE ( (source LIKE 'home' ESCAPE '\\') OR (source = '') )AND (language IN ('en', 'und'));
Empty set (0.00 sec)| Comment | File | Size | Author |
|---|---|---|---|
| redirect_db_index.patch | 679 bytes | jamiecuthill |
Comments
Comment #1
Mark Theunissen commentedI used devel generate to create 67 000 entries in the redirects table, and saw this slowdown, but it was not as severe as your 200ms, I saw 40ms for the redirect table query.
Adding the index to the table helps dramatically, making the query almost negligible. +1 for this.
Comment #2
dave reidMakes complete sense and makes me question why I didn't include it in the first place. Committed to 7.x-1.x.
http://drupalcode.org/project/redirect.git/commit/8a1bf55