0

Can I make PgBouncer preserve the PGOPTIONS environment variable in transaction pooling to configure GUC parameters? Or is there another way to configure these parameters in PgBouncer so that it applies to all connections?

I specifically need to set some pg_trgm parameters

Frederik Baetens
  • 781
  • 1
  • 9
  • 20
  • 2
    You could set the parameter in `postgresql.conf` or with `ALTER DATABASE` or `ALTER ROLE`. I think those are your only options. – Laurenz Albe Oct 02 '21 at 21:33
  • You can also set guc variables on a session level, with SET, (or transaction level with SET LOCAL), and I'm wondering if there's a way to make PgBouncer set a GUC parameter for every new connection to the database server. – Frederik Baetens Oct 03 '21 at 07:35
  • After looking at your profile, you're likely aware of these options, and mean that they're not possible with PgBouncer. Thanks for the answer :) – Frederik Baetens Oct 03 '21 at 15:29
  • Yes, I think there is no way to do that in pgBouncer. But I don't know every nook and cranny of pgBouncer. – Laurenz Albe Oct 04 '21 at 05:50

1 Answers1

1

You can use the connect_query option in database definitions, like

mydb = host=myhost dbname=mydb connect_query='set pg_trgm.similarity_threshold=0.5'

connect_query can be any SQL statement.

Peter Eisentraut
  • 35,221
  • 12
  • 85
  • 90