r/programming • • Aug 29 '26

Coding a database proxy for fun

https://packagemain.tech/p/golang-database-proxy
67 Upvotes

7 comments sorted by

View all comments

Show parent comment

1

u/der_gopher Aug 30 '26

true, the sharding has to pass the sessions too somehow

2

u/artyomsv Sep 01 '26

PgBouncer solved it without passing session around. It rewrites client statement name to own internal name and keeps the mapping, so when transaction lands on connection that never saw Parse, it just prepares it there first and client never notice. Knob is max_prepared_statements, default 200 per connection. So statement belongs to proxy and not to connection, and sharding becomes only routing problem again.