The multiple "values" syntax to my knowledge is not standard SQL (e.g.
is not available on any other database) and the bug in psycopg2 is that
they do not use prepared statements for executemany(). Looping over the
same INSERT statement many times is extremely fast when prepared
statements are used.
The multiple "values" syntax will also no longer exhibit the great
performance you see if you need to insert hundreds of thousands of rows.
Postgresql will be tasked with parsing a many-megabyte SQL string on
every invocation which is very wasteful both in terms of memory and
time.
Basically the multiple-values syntax is not at all portable and is very
awkward at every level. For the average SQL developer would be
extremely surprising if SQLAlchemy's use of normal DBAPI executemany
(
https://www.python.org/dev/peps/pep-0249/#id18) were arbitrarily
circumvented in this very specific case, leading to a new set of
behavioral quirks and issues. You should definitely contact the
psycopg2 developers and ask them as well why they don't switch to
multiple-VALUES within an executemany() as well as why they aren't on
prepared statements for this operation (if that's still the case).
>
> /Viktor
>
>
>
>
> --
> 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
sqlalchemy+...@googlegroups.com
> <mailto:
sqlalchemy+...@googlegroups.com>.
> To post to this group, send email to
sqlal...@googlegroups.com
> <mailto:
sqlal...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/sqlalchemy.
> For more options, visit
https://groups.google.com/d/optout.