Add performance diagnose rule to check useless prepare statement #18743
Labels
feature/accepted
This feature request is accepted by product managers
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
type/feature-request
Categorizes issue or PR as related to a new feature.
type/usability
Feature Request
As you can see, the client try to use the
prepared
statement, but theprepare
statement should only compile once.If the client has to prepare again before each execution, actually the performance is worse than not use prepare.
This Issue wants to add a diagnose rule to auto find this problem by diagnose.
How to diagnose?
You can simply check the statement count of
prepare
andexecute
. Normally, the statement count ofexecute
should much more than the statement count ofprepare
.And you can use the metrics tables to get this information.
here is a SQL you can use to diagnose:
If the upper SQL returns
0
, you can output a warning like:Describe alternatives you've considered:
The text was updated successfully, but these errors were encountered: