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

Avoid normalize parameter every operation in prepared query #1252

Merged
merged 1 commit into from
Dec 10, 2022

Conversation

neuecc
Copy link
Contributor

@neuecc neuecc commented Dec 10, 2022

If using prepared query,
SingleCommandPayloadCreator.WritePreparedStatement calls parameterCollection?.NormalizedIndexOf and it allocates string(Trim @).
However, since the Parameter of a Prepared Statement is always the same, if it is Normalized in advance, it will not be Allocated each time.

This PR adds List<string?> NormalizedParameterNames to ParsedStatement (ParsedStatement is only used prepared query).
Also added MySqlParameterCollection.UnsafeIndexOf, which is an IndexOf that expects the argument to be already normalized.

This improves the performance of Prepared Queries that are executed multiple times.

Copy link
Member

@bgrainger bgrainger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you affirm the Developer Certificate of Origin for this contribution? https://developercertificate.org/

@neuecc
Copy link
Contributor Author

neuecc commented Dec 10, 2022

Do you affirm the Developer Certificate of Origin for this contribution? https://developercertificate.org/

yes, and sorry for missed DCO.

@bgrainger bgrainger merged commit e3d0357 into mysql-net:master Dec 10, 2022
@bgrainger
Copy link
Member

Shipped in 2.2.3; thanks for the contribution!

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

Successfully merging this pull request may close these issues.

2 participants