I am running into anissue with a table I've loaded for months with no problems. There are 4,301,290,034 records in the LoanMonth table and each new month I insert approximately 40 million more. This last month I loaded the data as usual with no errors and the total record counts are correct. When I attempt to query the table for the most recently added data I get an empty set. When I check the explain plan I get the message "Impossible WHERE noticed after reading const tables " which doesn't make sense because I can query on any of the previous months data. I have recreated the table and indexes as well as reloaded the most recent month's data, but I am still getting the same empty set problem when I query for the last set of data I loaded. I have also verified that the data I am loading doesn't have any hidden, non-printable, or special characters.
Please take a look at the queries and their results below and let me know if anyone has any ideas of what could be causing this problem.
Thanks,
Scott
Version 5.0.75-0ubuntu10.3-log
Code:
mysql> desc LoanMonth;
+-----------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------------------+------+-----+---------+-------+
| LoanId | int(10) unsigned | NO | PRI | NULL | |
| AsOfMonth | smallint(5) unsigned | NO | PRI | NULL | |
+-----------+----------------------+------+-----+---------+-------+
mysql> show indexes from LoanMonth;
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| LoanMonth | 0 | PRIMARY | 1 | LoanId | A | 138751291 | NULL | NULL | | BTREE | |
| LoanMonth | 0 | PRIMARY | 2 | AsOfMonth | A | 4301290034 | NULL | NULL | | BTREE | |
| LoanMonth | 1 | LOAM_1_UK | 1 | AsOfMonth | A | 268 | NULL | NULL | | BTREE | |
| LoanMonth | 1 | LOAM_1_UK | 2 | LoanId | A | 4301290034 | NULL | NULL | | BTREE | |
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
Code:
mysql> select AsOfMonth, count(*)
from LoanMonth
where AsOfMonth = 376
group by AsOfMonth;
+-----------+----------+
| AsOfMonth | count(*) |
+-----------+----------+
| 376 | 39193907 |
+-----------+----------+
mysql> select AsOfMonth, count(*)
from LoanMonth
where AsOfMonth >= 376
group by AsOfMonth;
+-----------+----------+
| AsOfMonth | count(*) |
+-----------+----------+
| 376 | 39193907 |
| 377 | 39009879 |
+-----------+----------+
mysql> select AsOfMonth, count(*)
from LoanMonth
where AsOfMonth >= 377
group by AsOfMonth;
+-----------+----------+
| AsOfMonth | count(*) |
+-----------+----------+
| 377 | 39009879 |
+-----------+----------+
mysql> explain
select AsOfMonth, count(*)
from LoanMonth
where AsOfMonth >= 377
group by AsOfMonth;;
+----+-------------+-----------+-------+---------------+-----------+---------+------+----------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+-------+---------------+-----------+---------+------+----------+--------------------------+
| 1 | SIMPLE | LoanMonth | range | LOAM_1_UK | LOAM_1_UK | 2 | NULL | 85595562 | Using where; Using index |
+----+-------------+-----------+-------+---------------+-----------+---------+------+----------+--------------------------+
mysql> select AsOfMonth, count(*)
from LoanMonth
where AsOfMonth = 377
group by AsOfMonth;
Empty set (0.00 sec)
mysql> explain
select AsOfMonth, count(*)
from LoanMonth
where AsOfMonth = 377
group by AsOfMonth;
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+
| 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Impossible WHERE noticed after reading const tables |
+----+-------------+-------+------+---------------+------+---------+------+------+-----------------------------------------------------+