将C#连接到PgBouncer

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