-
Notifications
You must be signed in to change notification settings - Fork 9
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
psqlpy slower than psycopg #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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: |
I've made test with the 12th version of PostgreSQL (from you docker-compose).
|
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 |
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. |
@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. |
@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. |
Yeap, I understand. Library is young (4.5 months), so there are no a lot of activity yet |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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?
The text was updated successfully, but these errors were encountered: