Bug #4355 | Strange result on LEFT JOIN | ||
---|---|---|---|
Submitted: | 1 Jul 2004 3:22 | Modified: | 17 Jul 2004 15:35 |
Reporter: | Quentin Ochem | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.1.2-alpha | OS: | Windows (windows 2000) |
Assigned to: | CPU Architecture: | Any |
[1 Jul 2004 3:22]
Quentin Ochem
[14 Jul 2004 12:09]
Jochen Riehm
We experience the same bug on a Linux System with MySQL 3.23.57. In addition we have the following effect when counting NULL values of two different fields of a LEFT JOIN: Using count(distinct name) on both returns 0 for both fields Using count(name) on both also returns 0 for both fields Using count(name) for one and count(distinct name) for the other returns 1 for the first and 0 for the second field. The result was just one row with NULL for both fields (also only 1 row before grouping), so 0 for both fields would be correct.
[14 Jul 2004 12:36]
Jochen Riehm
Further research led to the following result: problem occured when the index used on the table with count(distinct name) had as cardinality NULL. Then the explain said: +-------+-------+---------------+------------+---------+------+------+------------------------------------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +-------+-------+---------------+------------+---------+------+------+------------------------------------------+ | b | range | PRIMARY | PRIMARY | 4 | NULL | 1 | where used; Using index; Using temporary | | ovb1 | index | id1 | id1 | 4 | NULL | 1 | Using index | | msg | ref | ******_id | *****_id | 5 | b.id | 53 | | +-------+-------+---------------+------------+---------+------+------+------------------------------------------+ (Table ovb whas the one with incorrect index) and the problem occured. After an optimize table the Index cardinality was set to 1 and the explain read: +-------+-------+---------------+------------+---------+------+------+-------------------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +-------+-------+---------------+------------+---------+------+------+-------------------------+ | b | range | PRIMARY | PRIMARY | 4 | NULL | 1 | where used; Using index | | ovb1 | ref | id1 | id1 | 4 | b.id | 1 | Using index | | msg | ref | *******_id | *******_id | 5 | b.id | 53 | | +-------+-------+---------------+------------+---------+------+------+-------------------------+ and the problem did not occure anymore.
[17 Jul 2004 15:35]
MySQL Verification Team
I wasn't able to repeat with version 4.1.3.
[21 Jul 2004 8:11]
Quentin Ochem
Did you try my request (the first reported) ? I updated mysql to 4.1.3 beta and I still get one result where I should find nothing...