News for hackers. Stuff that matters.
Re:Show HN: 1M rows/s from Postgres to Python by 1st1 on Thursday August 04, 2016 @03:38PM (#12227914)
asyncpg was developed by @redcrowbar and me. Ask us anything ;)
Re:Show HN: 1M rows/s from Postgres to Python by rdtsc on Thursday August 04, 2016 @03:48PM (#12227982)
Great work, thanks for sharing. Very impressive speed.

I didn't know about uvloop, that's a cool project:

http://magic.io/blog/uvloop-blazing-fast-python-networking/

Re:Show HN: 1M rows/s from Postgres to Python by 1st1 on Thursday August 04, 2016 @03:53PM (#12228017)
Yep, it's also much more stable now, 3 months after that article was posted. I plan to make a new blog post about it soon.
Re:Show HN: 1M rows/s from Postgres to Python by andrioni on Thursday August 04, 2016 @04:12PM (#12228121)
Do you have any numbers on queries that return millions of rows? If it's still fast, asyncpg could be nice for some ETL-type workloads.
Re:Show HN: 1M rows/s from Postgres to Python by 1st1 on Thursday August 04, 2016 @04:18PM (#12228147)
We haven't benchmarked this specific use case. However, cursors in asyncpg do data prefetching (the exact number of prefetched rows is configurable), so I expect that asynchronous iteration should be pretty fast (and still faster than psycopg2).
Re:Show HN: 1M rows/s from Postgres to Python by random42 on Thursday August 04, 2016 @03:50PM (#12227992)
May be I am reading the benchmarks wrong, but does it mean I can get a 2x speedup in my end to end query execution from moving from aiopg to asynpg alone without any server side changes or query optimizations?
Re:Show HN: 1M rows/s from Postgres to Python by RedCrowbar on Thursday August 04, 2016 @03:56PM (#12228031)
We intentionally benchmarked simple queries to measure the overhead of the driver implementation. So, the 2x speedup really means 50% reduction in overhead.
Re:Show HN: 1M rows/s from Postgres to Python by Keats on Thursday August 04, 2016 @04:22PM (#12228176)
I'd love to read the docs for the protocol itself, is it planned? Do you have a link explaining it otherwise?

Great work!

Re:Show HN: 1M rows/s from Postgres to Python by RedCrowbar on Thursday August 04, 2016 @04:25PM (#12228190)
The protocol is documented in the official PostgreSQL documentation: https://www.postgresql.org/docs/current/static/protocol.html
Re:Show HN: 1M rows/s from Postgres to Python by Keats on Thursday August 04, 2016 @05:09PM (#12228505)
I meant a doc explaining roughly the components at https://github.com/MagicStack/asyncpg/tree/master/asyncpg/pr... and how they interact with each other at a high level as it doesn't seem to have comments.

Thanks for the link though, I'll have a look

Re:Show HN: 1M rows/s from Postgres to Python by 1st1 on Thursday August 04, 2016 @05:39PM (#12228661)
Yeah, documenting internals sounds like a good idea. At least to make it easier for people to contribute and further improve asyncpg. We'll try to find some time to do that.
Re:Show HN: 1M rows/s from Postgres to Python by welder on Thursday August 04, 2016 @04:10PM (#12228105)
How can I use it with SQLAlchemy instead of psycopg2?
Re:Show HN: 1M rows/s from Postgres to Python by RedCrowbar on Thursday August 04, 2016 @04:18PM (#12228150)
SQLAlchemy ORM is not async, so there is no way currently to use any async dialect for it. However, it is possible to write an SQLAlchemy Core adapter for asyncpg.
Re:Show HN: 1M rows/s from Postgres to Python by infinite8s on Thursday August 04, 2016 @04:33PM (#12228245)
It might even be easier than writing an adapter if you just use SQLAlchemy Core's DSL as the generative mechanism for a SQL statement that is sent to asyncpg.
Re:Show HN: 1M rows/s from Postgres to Python by RedCrowbar on Thursday August 04, 2016 @04:38PM (#12228291)
There appears to be an adapter for Core already: https://github.com/CanopyTax/asyncpgsa
Re:Show HN: 1M rows/s from Postgres to Python by nhumrich on Friday August 05, 2016 @03:20AM (#12230591)
Author of asyncpgsa here, I am in the process of writing that, let me know if you have questions.
Re:Show HN: 1M rows/s from Postgres to Python by Veratyr on Thursday August 04, 2016 @03:46PM (#12227969)
Does this automatically escape/convert things like datetimes in a query or does that need to be done separately? The docs are a little sparse on details.

Looks fantastic anyway!

Re:Show HN: 1M rows/s from Postgres to Python by RedCrowbar on Thursday August 04, 2016 @03:53PM (#12228011)
Yes, query arguments are converted automatically. Results are converted into Python types as expected (including arrays and composite types).
Re:Show HN: 1M rows/s from Postgres to Python by glogla on Thursday August 04, 2016 @04:45PM (#12228338)
Bit offtopic, but what are the plots made with?
Re:Show HN: 1M rows/s from Postgres to Python by RedCrowbar on Thursday August 04, 2016 @04:46PM (#12228346)
Handmade with d3.js