Re: [sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-12 Thread Mike Bayer
I'm actually happy with those results. execute_batch is just a drop-in, while execute_values is more complicated since we have to intercept specific kinds of statements (INSERTS that have exactly one VALUES clause invoked against multiple parameter sets), and still may be more error prone. a 7% s

Re: [sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-11 Thread vineet
I ran some tests using raw psycopg2 on my local computer, and also ran some tests with SQLAlchemy. I misunderstood a few things in my tests above, but I've explained the tests below and think they are more accurate. *Context:* - Each test was run 5 times and averaged. - Both the python and datab

Re: [sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-11 Thread Mike Bayer
On Wed, Oct 11, 2017 at 3:02 AM, wrote: > Hey Mike, > > Thanks again for the detailed explanations! > > I went ahead and tested the code snippet you gave me - I'm not sure I > totally understand when this will change behavior though. > > I tried the following code snippet: > (Snippet #1) > for i

Re: [sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-11 Thread vineet
Hey Mike, Thanks again for the detailed explanations! I went ahead and tested the code snippet you gave me - I'm not sure I totally understand when this will change behavior though. I tried the following code snippet: (Snippet #1) for i in xrange(10): db.session.add(A(id=i)) db.session.flus

Re: [sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-10 Thread Mike Bayer
I've added https://bitbucket.org/zzzeek/sqlalchemy/issues/4109/support-psycopg2-batch-mode which will have a code review up soon. On Tue, Oct 10, 2017 at 1:06 PM, Mike Bayer wrote: > On Tue, Oct 10, 2017 at 1:47 AM, wrote: >> Hello! SQLAlchemy has the (really useful) behavior of batching toget

Re: [sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-10 Thread Mike Bayer
On Tue, Oct 10, 2017 at 1:47 AM, wrote: > Hello! SQLAlchemy has the (really useful) behavior of batching together > inserts when all the primary keys are defined. It looks like it groups > similar tables together (while maintaining insert order ) to minimize the > number of Insert statements sent

[sqlalchemy] How do Insert statements for single-table inheritance tables get batched together?

2017-10-09 Thread vineet
Hello! SQLAlchemy has the (really useful) behavior of batching together inserts when all the primary keys are defined. It looks like it groups similar tables together (while maintaining insert order ) to minimize the number of Insert statements sent to the database. I'm unsure what the expected