MySQL Statement mit "LOWER" umgeht vorhandenen Index

Hilfe zu OTRS Problemen aller Art
Post Reply
Dizzy
Znuny expert
Posts: 200
Joined: 12 Apr 2007, 14:30

MySQL Statement mit "LOWER" umgeht vorhandenen Index

Post by Dizzy »

Hallo zusammen,
seit einiger Zeit bin ich dabei, unser seit nun einigen Jahren gewachsenes OTRS zu optimieren.
Dabei bin ich über ein kurioses Verhalten bei Abfragen in der MySQL-Datenbank "gestolpert":

Bei Abfragen, welche eine "LOWER" Anweisung mitgeben, wird scheinbar der hinterlegte Index nicht berücksichtigt!

Beispiel:
SELECT profile_name FROM search_profile WHERE LOWER(login) = LOWER('TicketSearch::Benutzer1');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE search_profile ALL NULL NULL NULL NULL 9254 Using where

SELECT profile_name FROM search_profile WHERE (login) = LOWER('TicketSearch::Benutzer1');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE search_profile ref login login 602 const 5 Using where


Könnt ihr dies nachvollziehen und vielleicht sogar bestätigen?
Ich bin kein DB-Experte, aber lässt sich so ein Index auch "anders" setzen (so dass z.B. ein "LOWER-Index" für die Spalte "Login" erstellt wird?)

Die eigentliche Anweisung aus OTRS heraus lässt sich ermutlich nicht einfach so ohne weiteres ändern (LOWER Anweisung entfernen, was aber vielleicht auch gar nicht sinnvoll wäre), oder? :)


Ich hoffe meine Anfrage hat noch genügend Bezug zu OTRS, obwohl sie ja schon sehr auf Datenbank-spezifische Aspekte abzielt :?

Vielen Dank im voraus für eure "Ideen" :D
OTRS: 2.4.9 + ITSM 2.1.1 + CiCS 3.3.5
SLES 11
MySQL-Version: 5.1.49
Mike_B
Moderator
Posts: 266
Joined: 12 Jan 2010, 18:16
Znuny Version: CVS HEAD

Re: MySQL Statement mit "LOWER" umgeht vorhandenen Index

Post by Mike_B »

huntingbears.nl - @michielbeijen on Twitter
Dizzy
Znuny expert
Posts: 200
Joined: 12 Apr 2007, 14:30

Re: MySQL Statement mit "LOWER" umgeht vorhandenen Index

Post by Dizzy »

Yes, I've already seen this :-)
I didn't know about the "bugtracker" when I wrote the post in the OTRS Forum.
I'm excited if that will be fixed at least in OTRS 3.X!

Anyway, thanks for your comment and note :-)
OTRS: 2.4.9 + ITSM 2.1.1 + CiCS 3.3.5
SLES 11
MySQL-Version: 5.1.49
Post Reply