Apologize for my poor English.
While I debugging slow queries on my Drupal 7.12 site, I found a query in locale module is very slow.
I think the reason is that some modules will filter/sort {locales_target} table by `language` field, however it's not indexed.
Please see this function for example:
http://api.drupal.org/api/drupal/includes%21locale.inc/function/_locale_...
$result = db_query("SELECT s.lid, s.source, s.context, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.location LIKE '%.js%' AND s.textgroup = :textgroup", array(':language' => $language->language, ':textgroup' => 'default'));
Comments
Comment #1
droplet CreditAttribution: droplet commentedThere're indexes on both source & target language cols.
I think the main reason is here:
WHERE s.location LIKE '%.js%'
Comment #2
crifi CreditAttribution: crifi commentedChange to better title
Comment #3
Tobias Xy CreditAttribution: Tobias Xy commentedAdded the "Needs backport to D7" tag.
This query really(!!) slows down my site. Does anyone know a workaround? Quick and dirty would be ok, I guess...
Comment #10
apadernoComment #11
ndobromirov CreditAttribution: ndobromirov at FFW commentedThere could be stale / invalid translation strings present in the database.
Things that were once in code, but have been changed and re-translated etc.
With time this data starts to clutter the DB and resulted in bigger and bigger database result sizes, returning translations that will likely never get used again.
As far as I know there is no automated way to clean-up stale translations from DB...
On top of that this query should have some kind of cache around it, so it should only happen once in a while and not all the time...
Comment #18
zuernBernhard CreditAttribution: zuernBernhard commentedHm nothing happened here ? Currently run into the same thing still on D7 ...