-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[umbrella] Adding pg8000 as a database driver #9294
Comments
I'm slightly surprised that it'd be faster than the other connectors, given its written in python. Do you have benchmarks or blog posts or something to show its the case? |
On pypy, This comes from some rough
I don't have blogposts specifically for pg8000, but it's a matter of principle; pypy in general has a JIT in it's central premise, which speeds up pure python to machine code, and this blog post talks a bit about why pypy has poor performance with C APIs in general (it mentions CFFI being "better", but it's not on-par with performance it should be able to achieve, it's still not fully optimised). |
Similar to #9295 (comment), right now we're willing to accept that "postgres means pyscopg2" in Synapse, and we're not keen to explore other drivers until there's a clear motivating need. In this case, I'm pretty surprised by the psycopg2cffi timings, and suspect that our test suite is not producing representative results. As PyPy is technically unsupported by Synapse, we're not inclined to make invasive changes to enable that support. I'd be curious if psycopg2cffi fared better in something more closely approximating real-world conditions (e.g., maybe a load test using https://github.com/hpi-schul-cloud/synapse-load-test?) |
Using pg8000, a pure-python postgres database driver, will make it possible to use pypy in a performant manner, as pypy has poor interaction with it's C-API.
This issue is thus a sub-issue of #8888, and tracks progress in integrating pg8000 into the codebase.
TODO
BaseDatabaseEngine.sql_type
property to if-else based on"sqlite"
or"postgres"
PostgresEngine
toPsycoPg2Engine
(#XXXX)Pg8000Engine
(#XXXX)"postgres"
"virtual" database name to switch topsycopg2
on cpython, andpg8000
on pypy (#XXXX)with engine.new_conn() as conn:
-esc context manager usage everywhere, to ensure proper closure of cursors, transactions, and connections in pypy (#XXXX)The text was updated successfully, but these errors were encountered: