psqlpy slower than psycopg #64
Replies: 7 comments
-
Hello! Thank you for you benchmarks. First of all, let's see my results:
They are approximately the same. I'll make sure to explain why. So, what I found strange?
The correct (for you test) PSQLPy bench function is: async def bench() -> BenchTypedDict:
bench_time: BenchTypedDict = {"insert_bulk_time": 0.0, "get_bulk_time": 0.0}
try:
db_pool = (
ConnectionPoolBuilder()
.user(POSTGRESQL_USER)
.password(POSTGRESQL_PASSWORD)
.host(POSTGRESQL_HOST)
.port(POSTGRESQL_PORT)
.dbname(POSTGRESQL_DATABASE)
.build()
)
async with db_pool.acquire() as connection:
async with connection.transaction() as trans:
await create_table(trans)
start = time()
await insert_bulk(trans)
end = time() - start
bench_time["insert_bulk_time"] = end
start = time()
await get_bulk(trans)
end = time() - start
bench_time["get_bulk_time"] = end
await drop_table(trans)
finally:
db_pool.close() The main explanation: |
Beta Was this translation helpful? Give feedback.
-
I've made test with the 12th version of PostgreSQL (from you docker-compose).
|
Beta Was this translation helpful? Give feedback.
-
I Want transaction only apllied during insert bulk only not on entire function
It's the only version I had on my machine I will try on latest postgresql (16)
Great explanation next time I will try benchmark it using web server like fastapi with high rps. Maybe it will get different result |
Beta Was this translation helpful? Give feedback.
-
Okay, I thought you need transaction everywhere, because this is standart psycopg behavior:
You can try to use our psqlpy-stress to do it, just install bombardier and run application. |
Beta Was this translation helpful? Give feedback.
-
@BimaAdi If you dont mind, I can transfer the issue to discussions cuz it's not really an issue, more like discussion. If we'll find really downsides of PSQLPy, I'll be happy to improve performance. |
Beta Was this translation helpful? Give feedback.
-
@chandr-andr Ok, I don't mind is this issue become a discussion. I made this issue because there is 0 discussion on discussion tab and i read this issue #43 about benchmark as well. |
Beta Was this translation helpful? Give feedback.
-
Yeap, I understand. Library is young (4.5 months), so there are no a lot of activity yet |
Beta Was this translation helpful? Give feedback.
-
I made my own benchmark between psqlpy vs psycopg you can found the comparison and code in this github repo https://github.com/BimaAdi/psqlpy-vs-psycopg. I made 2 use case
I found that psqlpy is slower than psycopg. Here the result (all in second):
Insert Bulk Time
Get Bulk Time
Machine spec
Although by only small margin but psycopg consitently beat psqlpy. What's wrong with my benchmark? did I do something wrong? or maybe due to other factor?
Beta Was this translation helpful? Give feedback.
All reactions