Description:
Following query yields no results, but row is present.
mysql> select count(*) from cso.cso_eml where cso_id=15905477;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
Row is retrieved by another key.
mysql> select cso_id from cso.cso_eml where cso_st_no=980077784405539;
+----------+
| cso_id |
+----------+
| 15905477 |
+----------+
1 row in set (0.00 sec)
Row is retrieved by cast;
mysql> SELECT count(*) FROM `cso`.`cso_eml` where cast(cso_id as unsigned)=15905477;
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row in set (0.01 sec)
How to repeat:
Create a table with following primary key and auto-increment;
`CSO_ID` int(11) NOT NULL AUTO_INCREMENT,
mysql> select count(*) from cso.cso_eml;
+----------+
| count(*) |
+----------+
| 6193 |
+----------+
1 row in set (0.03 sec)
mysql> explain partitions select * from cso.cso_eml where cso_id=15905477;
+----+-------------+---------+------------+--------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+------------+--------+---------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | cso_eml | p15 | eq_ref | PRIMARY | PRIMARY | 4 | const | 1 | |
+----+-------------+---------+------------+--------+---------------+---------+---------+-------+------+-------+
1 row in set (0.00 sec)
mysql> explain partitions select * from cso.cso_eml where cast(cso_id as unsigned)=15905477;
+----+-------------+---------+---------------------------------------------------------------------------------------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+---------------------------------------------------------------------------------------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | cso_eml | p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23 | ALL | NULL | NULL | NULL | NULL | 6193 | Using where |
+----+-------------+---------+---------------------------------------------------------------------------------------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.01 sec)
mysql> explain partitions select cso_id from cso.cso_eml where cso_st_no=980077784405539;
+----+-------------+---------+---------------------------------------------------------------------------------------+------+------------------+------------------+---------+-------+------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+---------------------------------------------------------------------------------------+------+------------------+------------------+---------+-------+------+-------+
| 1 | SIMPLE | cso_eml | p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23 | ref | CSO_STRT_END_INX | CSO_STRT_END_INX | 8 | const | 123 | |
+----+-------------+---------+---------------------------------------------------------------------------------------+------+------------------+------------------+---------+-------+------+-------+
1 row in set (0.00 sec)