Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Planner doesn't rewrite conflict expressions to dual in utf8mb4_general_ci collation #55807

Open
Defined2014 opened this issue Sep 3, 2024 · 0 comments
Labels
report/customer Customers have encountered this bug. sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@Defined2014
Copy link
Contributor

Defined2014 commented Sep 3, 2024

Enhancement

mysql> create table t(a char(1));
Query OK, 0 rows affected (0.01 sec)
mysql> explain select * from t where a = 'C' and a = 'D';
+-------------------------+----------+-----------+---------------+--------------------------------------+
| id                      | estRows  | task      | access object | operator info                        |
+-------------------------+----------+-----------+---------------+--------------------------------------+
| TableReader_7           | 0.00     | root      |               | data:Selection_6                     |
| └─Selection_6           | 0.00     | cop[tikv] |               | eq(test.t.a, "C"), eq(test.t.a, "D") |
|   └─TableFullScan_5     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo       |
+-------------------------+----------+-----------+---------------+--------------------------------------+
3 rows in set (0.00 sec)

mysql> show variables like '%collation%';
+---------------------------------------+--------------------+
| Variable_name                         | Value              |
+---------------------------------------+--------------------+
| collation_connection                  | utf8mb4_general_ci |
| collation_database                    | utf8mb4_bin        |
| collation_server                      | utf8mb4_bin        |
| default_collation_for_utf8mb4         | utf8mb4_bin        |
| tidb_hash_exchange_with_new_collation | ON                 |
+---------------------------------------+--------------------+
5 rows in set (0.00 sec)

mysql> set collation_connection='utf8mb4_bin';
Query OK, 0 rows affected (0.00 sec)

mysql> explain select * from t where a = 'C' and a = 'D';
+-------------+---------+------+---------------+---------------+
| id          | estRows | task | access object | operator info |
+-------------+---------+------+---------------+---------------+
| TableDual_5 | 0.00    | root |               | rows:0        |
+-------------+---------+------+---------------+---------------+
1 row in set (0.01 sec)

I think when collation_connetion equals to utf8mb4_general_ci, the plan should also be TableDual

@Defined2014 Defined2014 added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner labels Sep 3, 2024
@Defined2014 Defined2014 changed the title Planner don't rewrite some conflict expressions to dual in some collations. Planner doesn't rewrite some conflict expressions to dual in some collations. Sep 3, 2024
@Defined2014 Defined2014 changed the title Planner doesn't rewrite some conflict expressions to dual in some collations. Planner doesn't rewrite some conflict expressions to dual in utf8mb4_general_ci collations. Sep 3, 2024
@Defined2014 Defined2014 changed the title Planner doesn't rewrite some conflict expressions to dual in utf8mb4_general_ci collations. Planner doesn't rewrite some conflict expressions to dual in utf8mb4_general_ci collation Sep 3, 2024
@Defined2014 Defined2014 changed the title Planner doesn't rewrite some conflict expressions to dual in utf8mb4_general_ci collation Planner doesn't rewrite conflict expressions to dual in utf8mb4_general_ci collation Sep 3, 2024
@Defined2014 Defined2014 added the report/customer Customers have encountered this bug. label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
report/customer Customers have encountered this bug. sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant