Disadvantages of quoting integers in a Mysql query?

The performance cost is that whenever mysql needs to do a type conversion from whatever you give it to datatype of the column. So with your query

SELECT col1,col2,col3 FROM table WHERE col1=’3′;

If col1 is not a string type, MySQL needs to convert ‘3’ to that type. This type of query isn’t really a big deal, as the performance overhead of that conversion is negligible.

However, when you try to do the same thing when, say, joining 2 table that have several million rows each. If the columns in the ON clause are not the same datatype, then MySQL will have to convert several million rows every single time you run your query, and that is where the performance overhead comes in.

Leave a Comment