问题
I am using C# and PostgreSQL. I have connected to PostgreSQL using Npgsql. Everthing is working fine. Now I want to use connection pooling with the help of PgBouncer tool.Database information has been set to PgBouncer. Because now PgBouncer will take care of connection to PostgreSQL database( If I am wrong, please correct me).
But the problem is that , I could not find the way to connect PgBouncer in C#.If anyone has done the same , please tell me.
Also is it good to use connection pooling in PostgreSQL instead of PgBouncer? if yes then please tell me how to do it.
Thanks
回答1:
Using pgbouncer with Npgsql simply means making Npgsql connect to pgbouncer instead of PostgreSQL directly - all you need to do is provider the host and port for pgbouncer.
Note that Npgsql comes with an efficient, built-in connection pool which in general should be preferred - make sure you have a good reason for using pgbouncer instead of the internal pooling. Npgsql pooling is on by default, if you want to use pgbouncer you should probably disable Npgsql pooling by passing Pooling=false
in your connection string.
Also is it good to use connection pooling in PostgreSQL instead of PgBouncer?
That doesn't really make any sense - PostgreSQL (your database server) doesn't provide any pooling on its own.
来源:https://stackoverflow.com/questions/44754319/connect-c-sharp-to-pgbouncer