Using LOWER() in a condition is slow as it can't use an index. It was necessary in D6 to ensure consistent, case insensitive comparisons as LIKE in MySQL does by default but requires ILIKE IN PostgreSQL.
DBTNG automatically uses the case insensitive version of LIKE wich allows to remove the LOWER().
| Comment | File | Size | Author |
|---|---|---|---|
| lower.patch | 544 bytes | berdir |
Comments
Comment #1
simon georges commentedPatch looks simple enough, but can you justify what you're saying about the DBTNG LIKE comparison ? I didn't find any reference to detail that. I'm willing to commit that as soon as I understand it ;-)
Comment #2
berdirSure, that's defined in http://api.drupal.org/api/drupal/includes--database--pgsql--database.inc... for PostgreSQL.
It might also be useful to add a test which can be run on MySQL and PostgreSQL for this, before commiting it..
Comment #3
simon georges commentedWhat about other database systems, like SQLLite, ... ? Do you know if some could eventually have a problem with the LIKE ? (I promise, it's my last question before the commit ;-)).
Comment #4
miro_dietikerIt's the job of the DB abstration layer to cover this cleanly.
You see, originally it was a string condition (that is NOT altered for DB backends).
While the new code suggestion adds a condition of type "LIKE" that allows to implement this condition type in custom SQL dialect.
Comment #5
simon georges commentedAgreed. And committed.
Should we let the issue open because it needs tests, or considering it's all part of the DB Layer and, thus, already covered by our existing tests ?
Comment #6
berdirKeeping this open to add some tests sounds good to me..
Comment #7
berdirComment #8
anavarreFor the record, Login Toboggan got the same issue: http://drupal.org/node/1138208
Comment #9
berdirComment #11
corvus_ch commented