pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Multiple simultaneous queries on single connection
3+ messages / 2 participants
[nested] [flat]

* Multiple simultaneous queries on single connection
@ 2009-08-17 12:49  Yeb Havinga <yeb.havinga@portavita.nl>
  0 siblings, 1 reply; 3+ messages in thread

From: Yeb Havinga @ 2009-08-17 12:49 UTC (permalink / raw)
  To: pgsql-sql

Hello list,

We want to access a postgres database with multiple queries / result 
sets that are read simultaneously (hence async). The documentation says 
explicitly that no new PQsendQuery can be send on the same channel 
before the pqgetresults has returned null. This means we need to use 
multiple connections.

The problem is that multiple connections (from the same application 
instance) do not share the same MVCC snapshot.

Is there a way to have two or more connections see each others 
uncommitted things?

Any thoughts?
Yeb Havinga




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Multiple simultaneous queries on single connection
@ 2009-08-19 01:35  Craig Ringer <craig@postnewspapers.com.au>
  parent: Yeb Havinga <yeb.havinga@portavita.nl>
  0 siblings, 1 reply; 3+ messages in thread

From: Craig Ringer @ 2009-08-19 01:35 UTC (permalink / raw)
  To: Yeb Havinga <yeb.havinga@portavita.nl>; +Cc: pgsql-sql

On 17/08/2009 8:49 PM, Yeb Havinga wrote:
> Hello list,
>
> We want to access a postgres database with multiple queries / result
> sets that are read simultaneously (hence async). The documentation says
> explicitly that no new PQsendQuery can be send on the same channel
> before the pqgetresults has returned null. This means we need to use
> multiple connections.
>
> The problem is that multiple connections (from the same application
> instance) do not share the same MVCC snapshot.
>
> Is there a way to have two or more connections see each others
> uncommitted things?

Not at present.

You should be able to use explicitly declared cursors and FETCH to 
interleave requests for results from one or more queries in the same 
transation using the one connection, but only one FETCH may be active at 
a time.

--
Craig Ringer



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Multiple simultaneous queries on single connection
@ 2009-08-19 15:15  Yeb Havinga <yeb.havinga@portavita.nl>
  parent: Craig Ringer <craig@postnewspapers.com.au>
  0 siblings, 0 replies; 3+ messages in thread

From: Yeb Havinga @ 2009-08-19 15:15 UTC (permalink / raw)
  To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: pgsql-sql

Hello Craig, list
>> Is there a way to have two or more connections see each others
>> uncommitted things?
>
> Not at present.
>
> You should be able to use explicitly declared cursors and FETCH to 
> interleave requests for results from one or more queries in the same 
> transation using the one connection, but only one FETCH may be active 
> at a time.
Thanks for your info. I verified with a pl/pgsql function that from a 
pl/pgsql perspective, this is a good solution. However, our client 
application needs to access the postgres backend with libpq. I'm 
currently looking at PQsendPrepare / PQSendQueryPrepared together with 
what the exec_execute_message does. Each of these has a portal name as 
parameter. It would be nice if PQgetResult could also provide a portal 
name to fetch a result from. The question is how to multiplex data from 
different portals on the tcp/ip connection, or maybe have more than one 
tcp/ip connection per PQconn object when more than one portal is active 
at the same time.

--
Yeb




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2009-08-19 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-08-17 12:49 Multiple simultaneous queries on single connection Yeb Havinga <yeb.havinga@portavita.nl>
2009-08-19 01:35 ` Craig Ringer <craig@postnewspapers.com.au>
2009-08-19 15:15   ` Yeb Havinga <yeb.havinga@portavita.nl>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox