asyncpg icon indicating copy to clipboard operation
asyncpg copied to clipboard

Upset best practice?

Open Jflick58 opened this issue 7 years ago • 3 comments

Hi,

I'm currently upserting around 2.5 million rows to Postgres. I replaced my previous use of Sqlalchemy + psycopg2 with Asyncpg, but I'm not seeing the performance gains I expected. I have a complex query statement that utilizes ON CONFLICT to upset. SQLalchemy has an ORM method for this, but I don't see anything equivalent in the Asyncpg docs. I currently use executemany and pass a list of tuples that were converted from a Pandas data frame. I don't think I would be able to perform my upset function using copy_records_to_table, can you advise on how to approach this with Asyncpg?

Jflick58 avatar Mar 22 '19 01:03 Jflick58

#295 should boost the executemany() manyfold. I'll try to find time to get it merged soon.

elprans avatar Mar 22 '19 15:03 elprans

Please do. We've chosen asyncpg for it's performance, and we have a lot of upserts, that are working hacky now.

pkeeper avatar Jul 19 '19 08:07 pkeeper

#295 has been merged, executemany performance should be much better in the next release.

elprans avatar Nov 26 '20 23:11 elprans