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
Performance issues with pgxpool #729
Comments
|
The issue might be the connection pool size. It appears the code is starting a new Go routine for every item -- depending on the nature of your workload this could be ideal or it could be very inefficient. But regardless, pgxpool has fairly conservative default max size. I don't think database/sql has any default max size. Try setting pgxpool.Config.MaxConns to 50 or 100 and see if it makes a difference. |
|
@jackc Also having really poor performance with pgxpool. Using just pgx a select on a table with 1 row is 60ms, but using pgxpool it is 800ms. |
|
Do you have a test case I could see? |
|
I would be very interested in seeing this too! |
|
It's very interesting issue. Do you have more details or it is a dead issue with no reply? |
|
I am no longer working on the project since it was pretty much something to get more familiar with golang. In the end, it was somewhat solved by being smarter about when to start a new goroutine in my case just like @jackc mentioned. |
|
Is there a solution to this issue? I'm experiencing this issue right now, however, increasing MaxConns seems to have no effect on the performance. With Pgx inserts and queries take ∼0.2ms while with PgxPool anywhere from 30-60ms. Any ideas? |
|
Perhaps try calling Acquire and then the query method on the conn instead of the query method directly on the pool. This will allow measuring the acquire and query time separately to more accurately determine where the delay is occurring. Also, check out https://pkg.go.dev/github.com/jackc/pgx/v5@v5.0.0/pgxpool#Pool.Stat. That may provide additional insight. |
|
For me also, trying to use acquire from a pool is insanely slower than a single traditional connection I already made a benchmark with go-wrk, you can check it here |
Okay, so I just switched to using the pgx interface from database/sql for everything. I think database/sql has it's own default connection pool so I tried to use the pgxpool(v4) with pgx. It is just a basic program that finds all video files in a folder and all it's children. Anyway, its heavily uses goroutines. So here are the timings:
The folder size is 412 GB with 1390 items. The documentation for pgxpool is pretty much non existent. So I'm currently using Exec() method for write queries and Query() for others. I'm a noob so well, it is probably my fault. Here is the link to the repo. So well, can anyone provide any suggestions or point to some sources on how to use pgx well?
The text was updated successfully, but these errors were encountered: