Bug #111528 Count queries cardinality mismatch
Submitted: 22 Jun 2023 2:04 Modified: 22 Jun 2023 13:27
Reporter: Pedro Ferreira Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:8.0.33 OS:Ubuntu (22.04)
Assigned to: CPU Architecture:x86 (x86_64)
Tags: count, COUNT DISTINCT

[22 Jun 2023 2:04] Pedro Ferreira
Description:
In the attachment I am going to send, create the table, insert, and run the queries:

SELECT COUNT(t0.c0) FROM t0 GROUP BY t0.c0, t0.c1;
SELECT COUNT(DISTINCT t0.c0) FROM t0 GROUP BY t0.c0, t0.c1;

The first query returns 586 rows, while the second returns 585. I expect both queries to return the same number of rows.

The compilation parameters are the same as issue 108148:

-DWITH_DEBUG=1 -DWITH_ASAN=ON -DWITH_UBSAN=ON and boost library version 1.77

How to repeat:
Run the queries in the attachment.
[22 Jun 2023 2:04] Pedro Ferreira
File to reproduce issue

Attachment: issue.sql (application/octet-stream, text), 70.71 KiB.

[22 Jun 2023 13:27] MySQL Verification Team
Hi Mr. Perreira,

Thank you for your bug report.

However, it is not a bug.

We have ran additional queries and the results returned are correct.

Simply, there were two rows with duplicate values for the column `c1`. 

When you do not include aggregating columns in the SELECT list , then MySQL does it for you, although it does not include it int the result set.

Not a bug.