Bug #60457 | Select is not using index | ||
---|---|---|---|
Submitted: | 14 Mar 2011 9:00 | Modified: | 15 Mar 2011 9:10 |
Reporter: | Satyapal Garhwal | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 5.5.9 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | Select is not using index |
[14 Mar 2011 9:00]
Satyapal Garhwal
[14 Mar 2011 9:12]
Valeriy Kravchuk
Please, send the output of: SELECT count(*) FROM core_variant_combination_details WHERE variant_combination_number = 15214; SHOW TABLE STATUS LIKE 'core_variant_combination_details'\G SELECT count(distinct variant_combination_number) FROM core_variant_combination_details; from your environment. Send also the results of EXPLAIN for your problematic query.
[15 Mar 2011 5:06]
Satyapal Garhwal
sorry i did a mistake i am using WHERE variant_combination_number = 15214; integer 15214 in varchar column .... so that it is not using index if i use WHERE variant_combination_number = '15214'; it is using index
[15 Mar 2011 9:10]
Valeriy Kravchuk
Then this is not a bug. Read the manual, http://dev.mysql.com/doc/refman/5.5/en/type-conversion.html: "For comparisons of a string column with a number, MySQL cannot use an index on the column to look up the value quickly. If str_col is an indexed string column, the index cannot be used when performing the lookup in the following statement: SELECT * FROM tbl_name WHERE str_col=1; The reason for this is that there are many different strings that may convert to the value 1, such as '1', ' 1', or '1a'."