Postgres:连接中的并发查询 [英] Postgres: Concurrent queries in a connection

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

问题描述

在Postgres中,每个连接只能有一个执行查询的限制(连接中的其他查询要等到第一个查询完成才开始)?我想我在一个驱动程序中看到了这个,所以我想确保这是数据库行为,而不是特定的驱动程序限制。

解决方案

< blockquote>

在Postgres中,每个连接只能执行一个查询。


是。 PostgreSQL不允许您暂停和恢复事务,也不支持服务器后端的后台(异步)查询。



您仍然可以运行多个并发查询,每个并发查询只需要一个连接。您可以使用线程(每个连接一个线程),但是通常最好在客户端库中使用异步查询接口。



不知道您要实现的目标,并且您正在使用什么编程语言(以及什么客户端库)很难提供更详细的建议。


In Postgres is there a limitation of having just one executing query per connection (and other queries in the connection wait for the first to complete before they start)? I think I am seeing this in one driver so I want to be sure this is a db behavior and not a specific driver limitation.

解决方案

In Postgres is there a limitation of having just one executing query per connection

Yes. PostgreSQL doesn't let you suspend and resume transactions, nor does it support background (asynchronous) queries on the server back-end.

You can still run multiple concurrent queries, you just need one connection per concurrent query. You can use threads (one thread per connection) but it's usually better to use asynchronous query interfaces in your client library.

Without knowing what you're trying to achieve, and what what programming language (and thus what client library) you're using it's hard to offer more detailed advice.

这篇关于Postgres:连接中的并发查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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