问题
How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column?
回答1:
Yes, as MySQL doesn't support function-based indexes (like ADD INDEX myIndex(LENGTH(text))), you'll need a new int column and define a trigger to auto-update it after inserts and updates.
回答2:
Sounds like a good approach to me (sorry don't know mysql, but in oracle you could set a trigger so that when your main column is updated the "length" column gets automatically updated)
来源:https://stackoverflow.com/questions/84346/create-an-index-on-a-mysql-column-based-on-the-length-its-contents