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: show the reason why cannot hit plan cache for EXECUTE statements accessing partition tables #50407

Closed
qw4990 opened this issue Jan 15, 2024 · 1 comment · Fixed by #50505
Assignees
Labels
epic/plan-cache sig/planner SIG: Planner type/enhancement The issue or PR belongs to an enhancement.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Jan 15, 2024

Enhancement

See the case below, when executing PREPARE statement, it returns the exact reason why this query cannot hit the plan cache.
But later when executing EXECUTE statement, no warning to explain why it cannot hit the plan cache.

mysql> create table t (a int) partition by hash(a) partitions 4;
Query OK, 0 rows affected (0.01 sec)

mysql> analyze table t;
Query OK, 0 rows affected, 4 warnings (0.03 sec)

mysql> prepare st from 'select * from t';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-----------------------------------------------------------------------------+
| Level   | Code | Message                                                                     |
+---------+------+-----------------------------------------------------------------------------+
| Warning | 1105 | skip prepared plan-cache: query accesses partitioned tables is un-cacheable |
+---------+------+-----------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> execute st;
Empty set (0.00 sec)

mysql> show warnings;
Empty set (0.00 sec)

mysql> execute st;
Empty set (0.00 sec)

mysql> select @@last_plan_from_cache;
+------------------------+
| @@last_plan_from_cache |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.00 sec)
@qw4990 qw4990 added type/enhancement The issue or PR belongs to an enhancement. sig/planner SIG: Planner epic/plan-cache labels Jan 15, 2024
@qw4990
Copy link
Contributor Author

qw4990 commented Jan 15, 2024

@hawkingrei Please take a look at this issue, THX!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment