Skip to content

Avoid normalize parameter every operation in prepared query - #1252

Merged
bgrainger merged 1 commit into
mysql-net:masterfrom
neuecc:improve-prepared-execution
Dec 10, 2022
Merged

Avoid normalize parameter every operation in prepared query#1252
bgrainger merged 1 commit into
mysql-net:masterfrom
neuecc:improve-prepared-execution

Conversation

@neuecc

@neuecc neuecc commented Dec 10, 2022

Copy link
Copy Markdown
Contributor

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.

@bgrainger bgrainger left a comment

Copy link
Copy Markdown
Member

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

neuecc commented Dec 10, 2022

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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