Bug #115330 suggestion for query plan display of access path `unqualified_count`
Submitted: 14 Jun 7:24 Modified: 14 Jun 7:28
Reporter: ximin liang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S4 (Feature request)
Version:8.4.0 OS:Any
Assigned to: CPU Architecture:Any

[14 Jun 7:24] ximin liang
Description:
Hello mysql team:
  Here is a suggestion for query plan display of accesspath `unqualified_count`.

How to repeat:
Can be repeated in MySQL 8.4.0. Seems t2, t3 should be added in query plan.

create table t1(c1 int);
create table t2 like t1;
create table t3 like t2;
explain format=tree select count(*) from t1,t2,t3;
+----------------------+
| EXPLAIN              |
+----------------------+
| -> Count rows in t1
 |
+----------------------+

Suggested fix:
here is my test patch based on 8.4.0 :
@@ -1357,7 +1357,11 @@ static unique_ptr<Json_object> SetObjectMembers(
     case AccessPath::UNQUALIFIED_COUNT:
       error |= AddMemberToObject<Json_string>(obj, "access_type", "count_rows");
       error |= AddTableInfoToObject(obj, join->qep_tab->table());
-      description = "Count rows in " + string(join->qep_tab->table()->alias);
+      description = "Count rows in ";
+      for (uint i = 0; i < join->primary_tables; i++) {
+        description += string(join->qep_tab[i].table()->alias);
+        if (i + 1 != join->primary_tables) description += string(", ");
+      }
       break;
     case AccessPath::NESTED_LOOP_JOIN: {
       string join_type = JoinTypeToString(path->nested_loop_join().join_type);

and result:
mysql> explain format=tree select count(*) from t1,t2,t3;
+------------------------------+
| EXPLAIN                      |
+------------------------------+
| -> Count rows in t1, t2, t3
 |
+------------------------------+
[14 Jun 7:28] MySQL Verification Team
Hello ximin liang,

Thank you for the enhancement request.

regards,
Umesh
[30 Sep 16:54] Omer Barnir
Also see contribution in bug#115296 (https://bugs.mysql.com/bug.php?id=115296&contribs=1)