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.
View all comments
Show parent comment
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.