connect C# to PgBouncer

半腔热情 提交于 2019-12-08 14:09:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!