I have a large table (MyISAM) with id as the primary key (MySQL version 5.1.54).
When I execute the following query with a very large QUOTED integer in WHERE, it does not use the PK index and is very slow (it takes a few minutes):
update BIG_TABLE set some_value=0 where id='10000000000';
If I remove quotes, the query is very fast (PK Index is used correctly). This is fast:
update BIG_TABLE set some_value=0 where id=10000000000;
If I do not use a large integer value, the query is executed quickly even with quotation marks:
update BIG_TABLE set some_value=0 where id='100';
So, it looks like MySQL is not using the index for the integer column when the value in WHERE cannot be converted to integer (the value is too large for the integer). Is there a workaround for this?
I need a workaround from MySQL. Since this request is created by some closed perl library, which cannot be modified. All WHERE arguments are quoted automatically, and it sometimes happens that the Update query is built with a very large integer (this is an illegal value, so I just expect UPDATE to not update anything).
What is currently happening is that this update request runs for several minutes and it displays the whole system.
Note that the selection works correctly even when quoting large integers. No problem with this:
select * from BIG_TABLE where id='10000000000';
This is something with UPDATE.
Any ideas? Thanks!
Dima L.
source share