I'm using MySQL version 5.1 at my workplace.
I have a column
my_cloumn char(10) in
I recently found that a process was taking longer, and the SQL that was responsible for this was below:
SELECT * FROM my_table WHERE my_column = 12345, which can take some 3 minutes running.
Now, editing and using quotes on the search string this way
SELECT * FROM my_table WHERE my_column = '12345'
retrieves the record in a matter of micro seconds.
I do not have access (direct or indirect) to have the code changed to pass the queries with the quotes (by either direct sql or specifying the correct data type in PDO), and currently may not be able to change the column whilst users are using the database. What I need most is how to explain the difference above.
Why is this faster with quotes and not without?