2 ms·
> I thought you hated connection pools? No, you're just being unnecessarily rude. I just said I thought that fine-grained checkin-checkout like Go and Rust enc
by jashmatthews 8y ago
> I thought you hated connection pools?
No, you're just being unnecessarily rude. I just said I thought that fine-grained checkin-checkout like Go and Rust encourage is somewhat overrated. There's no need to be hostile.
> Postgres specifically supports unnamed prepared statements as a feature, and PgBouncer's model cannot do anything to help those.
PqExecParams (single phase prepared statement) works fine over PgBouncer. That's what I'm talking about. This is different to PREPARE & EXEC. You can't actually do a single phase prepared statement from psql, AFAIK, only via client libraries. https://www.postgresql.org/docs/11/libpq-exec.html https://www.postgresql.org/docs/11/libpq-exec.html
I agree, the PgBouncer documentation could be clearer. I think they just don't want people trying it to file bug reports. PREPARE and EXEC can actually work even over statement pooling but you need to make sure your connection setup statements prepare all the necessary statements.
> it's a synchronous process, unless you specifically launch that query in its own separate goroutine
You're right, I'm getting two things mixed up here. It is a while since I dealt with this problem.
1) The auto-checkout can mean you end up executing related statements on different connections. IMHO this is highly confusing to have as default behaviour and I prefer the Rust approach.
2) By default Go will just keep piling up Goroutines blocked on slow queries and open more DB connections and kill a DB server.
Reference for both: http://go-database-sql.org/connection-pool.html http://go-database-sql.org/connection-pool.html
> Rust database pools provide an option to limit the upper bound
If you're using Rust + Diesel + PG it's actually limited to 10 by default via R2D2: https://github.com/sfackler/r2d2/blob/ad9cdb9f1446c729240cf82d021f8e33e7cfe404/src/config.rs#L54 https://github.com/sfackler/r2d2/blob/ad9cdb9f1446c729240cf8...
I really think that's a lot saner than "open as many DB connections as you like, what could possibly Go wrong"
If you don't believe me that Diesel and single phase prepared statements work with PgBouncer, believe the Diesel maintainer, Sean Griffin: https://github.com/diesel-rs/diesel/issues/1028 https://github.com/diesel-rs/diesel/issues/1028
I'm back to working in Rust again and plan on opening a PR to resolve this issue.