Bypass normalization of already prepared statements.
- The normalization we do in vtgate during planning before checking the plan cache is expensive for large statements (think multi-value inserts).
- For statements that are already prepared, normalizing them adds little value, so we should bypass that.
The only thing to consider here is whether we should make this configurable behavior.
For a bit of performance context, on a workload where prepared statements are used to insert 100 rows into a 40-way sharded table at a time, this chops the plan time for each query in half in my test environment (from ~ 4 ms per query to < 2 ms per query).
As context; the use-case here are large inserts into MySQL backend(s) that are pretty speedy (running on bare metal), and the actual overall time spent per insert is 8-10 ms; so the plan time ends up being almost 50% of that...
For release notes:
In previous Vitess releases, prepared statement queries were normalized by vtgate if
-normalize_queries is true (which it is by default). We have introduced the new
vtgate flag -normalize_prepared_stmts which defaults to false. This changes the
default behavior of vtgate to *not* normalize prepared statements, but still
normalize non-prepared statement queries. This can increase performance
if your workload is prepared statement heavy, by reducing the CPU overhead
in vtgate, and by reducing the planning latency, especially for large queries. You
can revert to the previous vtgate behavior by setting the -normalize_prepared_stmts
flag to true.
This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:
- Push additional commits to the associated branch.
- Remove the stale label.
- Add a comment indicating why it is not stale.
If no action is taken within 7 days, this PR will be closed.
This PR was closed because it has been stale for 7 days with no activity.
Review Checklist
Hello reviewers! :wave: Please follow this checklist when reviewing this Pull Request.
General
- [ ] Ensure that the Pull Request has a descriptive title.
- [ ] If this is a change that users need to know about, please apply the
release notes (needs details)label so that merging is blocked unless the summary release notes document is included.
If a new flag is being introduced:
- [ ] Is it really necessary to add this flag?
- [ ] Flag names should be clear and intuitive (as far as possible)
- [ ] Help text should be descriptive.
- [ ] Flag names should use dashes (
-) as word separators rather than underscores (_).
If a workflow is added or modified:
- [ ] Each item in
Jobsshould be named in order to mark it asrequired. - [ ] If the workflow should be required, the maintainer team should be notified.
Bug fixes
- [ ] There should be at least one unit or end-to-end test.
- [ ] The Pull Request description should include a link to an issue that describes the bug.
Non-trivial changes
- [ ] There should be some code comments as to why things are implemented the way they are.
New/Existing features
- [ ] Should be documented, either by modifying the existing documentation or creating new documentation.
- [ ] New features should have a link to a feature request issue or an RFC that documents the use cases, corner cases and test cases.
Backward compatibility
- [ ] Protobuf changes should be wire-compatible.
- [ ] Changes to
_vttables and RPCs need to be backward compatible. - [ ]
vtctlcommand output order should be stable andawk-able. - [ ] RPC changes should be compatible with vitess-operator
- [ ] If a flag is removed, then it should also be removed from VTop, if used there.
@vmg I think I addressed the last outstanding comment. Let me know if there is anything else I should address. I saw @aquarapid mention above about release notes. Should I add those here as part of this PR?
This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:
- Push additional commits to the associated branch.
- Remove the stale label.
- Add a comment indicating why it is not stale.
If no action is taken within 7 days, this PR will be closed.
This PR was closed because it has been stale for 7 days with no activity.