-
-
Notifications
You must be signed in to change notification settings - Fork 393
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
Insert cleanup #54
Insert cleanup #54
Conversation
Pull Request Test Coverage Report for Build 240
💛 - Coveralls |
Pull Request Test Coverage Report for Build 214
💛 - Coveralls |
20e948f
to
dbf7646
Compare
235554f
to
c39b21c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, great PR! Thank you for hard work, seeing Tortoise speeding up little by little in benchmark really feels good.
Also - do you have account on pypi? I would like to add you as maintainer of package
tortoise/backends/base/executor.py
Outdated
# Insert should implement returning new id to saved object | ||
# Each db has it's own methods for it, so each implementation should | ||
# go to descendant executors | ||
raise NotImplementedError() # pragma: nocoverage | ||
|
||
async def execute_insert(self, instance): | ||
self.connection = await self.db.get_single_connection() | ||
key = '%s:%s' % (self.db.connection_name, self.model._meta.table) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this kind of formatting gives any significant speedup?
If not, I think following .format()
would be better, cause it feels really much more pythonic way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, no idea.
I tend to use the % formatting over the .format() out of habit.
I just did a quick search, and, yep. that is the only such code in the codebase. I'll change it.
Yes, people get excited about performance 😁 |
This branch started with the goal of using prepared statements for inserts, but ended up being a general purpose insert/Client related cleanup.
Work done:
_prepare_insert_columns
and_prepare_insert_values
now do what they are calledexecute_insert()
methodvalues
as a DB driver parameter (Building prepared statements kayak/pypika#163 is stalled, do something slightly hacky in the interm)(We need to try and get this into pypika, asasyncpg
needs prepared statements to perform well)Not related to inserts:
This should be the last performance-oriented PR from me for now, performance is up over double (and much more for sqlite)