-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Optimize sqlutils.ToSqlite3Dialect
for queries + DML/DDLs
#17113
Optimize sqlutils.ToSqlite3Dialect
for queries + DML/DDLs
#17113
Conversation
Signed-off-by: Tim Vaillancourt <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
Signed-off-by: Tim Vaillancourt <[email protected]>
sqlutils.ToSqlite3Dialect
for insertssqlutils.ToSqlite3Dialect
for queries + DML/DDLs
@GuptaManan100 do we still need this library at all? |
@mattlord this is what I asked/proposed in this thread 👍. I'm hoping we can remove dialect translation and just use sqlite dialect Also I think EDIT: an alternative I've enjoyed using is https://github.com/jmoiron/sqlx, but not sure how dependency-heavy it is. I'm 95% sure it will handle anything |
Signed-off-by: Tim Vaillancourt <[email protected]>
I think removing the translation and writing queries directly that work with sqlite is a good idea indeed. It removes this whole layer of translation that doesn't really serve any purpose anymore.
I think it's a good idea to clean this up (also fine incrementally). It's all leftovers from how it was basically vendored but only parts have been modernized to match how other parts of Vitess work. So I think thinks kind of cleanup is also very welcome. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17113 +/- ##
==========================================
- Coverage 67.17% 67.17% -0.01%
==========================================
Files 1571 1571
Lines 252246 252258 +12
==========================================
+ Hits 169458 169465 +7
- Misses 82788 82793 +5 ☔ View full report in Codecov by Sentry. |
Yes, @timvaillancourt we can get rid of all other dialects other than sqlite. We don't allow any other backing database in VTOrc. |
Closing in favour of #17124 which removes the translation entirely |
Description
This PR adds some slight optimisations to
sqlutils.ToSqlite3Dialect
, a function we've noticed to take up a significant amount of CPU time invtorc
when it watches many instances, primarily due to large insert queries needing to be parsed byregexp
filtersProfile SVG (need to enlarge):
All this change does is assumes inserts happen more frequently than alter/create. Moving inserts to be checked sooner and separating read queries causes them to have to go through fewer regex matches (still a lot 🙈). The expense of queries that are not insert, alter or create is unchanged.
On Slack's
vtorc
instances this gave us about a 15-20% reduction in user-CPU used byvtorc
vs the previous avgIn the benchmark I added in the PR the difference is more like 8-9% for big inserts and 18-19% for reads
Before
After
Related Issue(s)
Resolves #17114
Checklist
Deployment Notes