<p dir="auto"><strong>Migrated issue, originally created by charles pierre (<a href="https://github.com/cp2587">@cp2587</a>)</strong></p>
<p dir="auto">Hello,</p>
<p dir="auto">Thanks for the fantastic job you did on this library.</p>
<p dir="auto">I recently came across a shortcoming of the actual psycopg2 library: apparently the executemany function is not optimized at all and just do a loop over execute.</p>
<p dir="auto">In regard to sqlalchemy, this mean that your recommended way of doing massive insert/update statements is actually really slow when working with psycopg2.</p>
<p dir="auto">For me, the difference between using execute(insert(), ..) or bulk_insert_mappings (which in the end, just execute a tons of single INSERT statement) and doing .insert().values() (which construct the correct INSERT ... VALUES), was like day and night.</p>
<p dir="auto">Maybe you could add a warning or note in your documentation regarding the use of psycopg2 in the relevant section of your docs (for instance, here, <a href="http://docs.sqlalchemy.org/en/latest/faq/performance.html#i-m-inserting-400-000-rows-with-the-orm-and-it-s-really-slow" rel="nofollow">http://docs.sqlalchemy.org/en/latest/faq/performance.html#i-m-inserting-400-000-rows-with-the-orm-and-it-s-really-slow</a>) ?</p>
<p dir="auto"><strong>Migrated issue, originally created by Michael Bayer (<a href="https://github.com/zzzeek">@zzzeek</a>)</strong></p>
<p dir="auto">as described at <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="193060614" data-permission-text="Title is private" data-url="https://github.com/psycopg/psycopg2/issues/491" data-hovercard-type="issue" data-hovercard-url="/psycopg/psycopg2/issues/491/hovercard?comment_id=276551038&amp;comment_type=issue_comment" href="https://github.com/psycopg/psycopg2/issues/491#issuecomment-276551038">psycopg/psycopg2#491 (comment)</a> we really need a hook to use psycopg2 batch mode so lets get that in.</p>