Does index on a varchar column make the query run slower? I can make that be int. and I don't need to do the LIKE % comparison.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Faster loop: foreach vs some (performance of jsper
If you can replace your varchar column with an integer (which i think is what your hinting at) Then an index including the integer column will perform better than the varchar column for a few reasons.
Indexing don't make query slower, database size just get bigger, So go ahead and give it a try.
You should able to get better performance on fetching rows but its depends on your data, your queries.
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.Be aware that using:
...will not use an index, but the following will:
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.
You are not going to be making your queries any slower by indexing. If you can make the column a type int, I would recommend doing so as most RDBMS's can search int's faster than varchars
There are performance issues when it comes to inserts. I can for sure tell you that inserting into a large table which has an index over a varchar column can be very slow. (up to 50x)