Does index on a varchar column make the query run slower?
No, it does not.
If the optimizer decides to use of the index, the query will run faster. INSERT
s/UPDATE
s/DELETE
s on that table will be slower, but not likely enough to notice.
I don't need to do the LIKE % comparison
Be aware that using:
LIKE '%whatever%'
...will not use an index, but the following will:
LIKE 'whatever%'
The key is wildcarding the lefthand side of the string means that an index on the column can't be used.
Also know that MySQL limits the amount of space set aside for indexes - they can be up to 1000 bytes long for MyISAM (767 bytes for InnoDB) tables.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…