On Wednesday, December 16, 2015 at 8:33:18 AM UTC-5, [email protected] 
wrote:
>
> As an application developer you would expect that these code snippets 
> would have the same performance characteristics and we were very surprised 
> at first at the results. 
>

No, you shouldn't -  especially when SQL is involved.  Incredibly slight 
changes to a query can drastically alter how a database performs a task, 
and each database behaves differently.


We think this is an issue, since it is a surprising behavoir from a 
> application developers point of view (preferbly you should not need to know 
> the details of the underlaying db driver in the application layer) 
>

 SqlAlchemy provides a unified way to use multiple databases with multiple 
drivers, and drivers are subject to constantly change.  You don't need to 
know the details of the underlying driver to write functional code, but 
you're not talking about that -- you're talking about optimizing how 
sqlalchemy handles two similar (but different) situations with the psycopg2 
driver.

This is also basically stated in the docs already:

  
  
http://docs.sqlalchemy.org/en/latest/core/dml.html#sqlalchemy.sql.expression.Insert.values

    It is essential to note that *passing multiple values is NOT the same 
as using traditional executemany() form*. The above syntax is a *special 
*syntax 
not typically used. To emit an INSERT statement against mutliple rows, the 
normal method is to pass a mutiple values list to theConnection.execute() 
<http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Connection.execute>
 method, 
which is supported by all database backends and is generally more efficient 
for a very large number of parameters.

    See also

    Executing Multiple Statements 
<http://docs.sqlalchemy.org/en/latest/core/tutorial.html#execute-multiple> - 
an introduction to the traditional Core method of multiple parameter set 
invocation for INSERTs and other statements.


there are typos in there, so I should do a PR on the docs!


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to