将C#连接到PgBouncer [英] connect C# to PgBouncer

查看:79
本文介绍了将C#连接到PgBouncer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#和PostgreSQL。我已经使用Npgsql连接到PostgreSQL。一切都很好。现在我想在PgBouncer工具的帮助下使用连接池。数据库信息已设置为PgBouncer。因为现在PgBouncer将处理与PostgreSQL数据库的连接(如果我错了,请更正我)。

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).

但是问题是,我找不到在C#中连接PgBouncer的方法。如果有人这样做,请告诉我。

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.

在PostgreSQL中使用连接池代替PgBouncer很好吗?如果是,那么请告诉我该怎么做。

Also is it good to use connection pooling in PostgreSQL instead of PgBouncer? if yes then please tell me how to do it.

谢谢

推荐答案

将pgbouncer与Npgsql一起使用仅意味着使Npgsql直接连接到pgbouncer而不是PostgreSQL-您需要做的就是提供pgbouncer的主机和端口。

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.

请注意,Npgsql带有一个高效的内置连接池,通常应该优先选择它-确保您有充分的理由使用pgbouncer而不是内部池。 Npgsql池在默认情况下处于打开状态,如果要使用pgbouncer,则可能应通过在连接字符串中传递 Pooling = false 来禁用Npgsql池。

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.


在PostgreSQL中使用连接池代替PgBouncer很好吗?

Also is it good to use connection pooling in PostgreSQL instead of PgBouncer?

这实际上没有任何意义-PostgreSQL(您的数据库服务器)本身没有提供任何池。

That doesn't really make any sense - PostgreSQL (your database server) doesn't provide any pooling on its own.

这篇关于将C#连接到PgBouncer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆