4

Can we create functional indexes in MySql for UPPERCASE and LOWERCASE functions.

I have searched but could not find anything relevant in the internet, if some has one implemented such a thing.

Opal
  • 81,889
  • 28
  • 189
  • 210

2 Answers2

5

Yes, MySQL 8.0.13 added indexed expressions.

create index upper_col1 on my_table ( (upper(col1)) )
Schwern
  • 153,029
  • 25
  • 195
  • 336
1

As per this post it is not generally possible to create a function based index, though you could use a sub string (from beginning).

Probably the closest you can get in MySQL is, if you add another (indexed) column and use an UPDATE trigger that assigns the results of your function to it.

Community
  • 1
  • 1
Trinimon
  • 13,839
  • 9
  • 44
  • 60