From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com> |
Cc: | Ilya Roublev <iroublev(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: multithreading in Batch/pipelining mode for libpq |
Date: | 2017-04-22 01:21:47 |
Message-ID: | 20170422012147.cikgolxvwnztvl53@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2017-04-22 09:14:50 +0800, Craig Ringer wrote:
> 2) if the answer to the previous question is negative, is it possible to
> send asynchronous queries in one thread while reading results in another
> thread?
>
>
> Not right now. libpq's state tracking wouldn't cope.
>
> I imagine it could be modified to work with some significant refactoring.
> You'd need to track state with a shared fifo of some kind where dispatch
> outs queries on the fifo as it sends them and receive pops them from it.
FWIW, I think it'd be a *SERIOUSLY* bad idea trying to make individual
PGconn interactions threadsafe. It'd imply significant overhead in a lot
of situations, and programming it would have to become a lot more
complicated (since you need to synchronize command submission between
threads). For almost all cases it's better to either use multiple
connections or use a coarse grained mutex around all of libpq.
- Andres
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2017-04-22 01:22:09 | Re: Old versions of Test::More |
Previous Message | Craig Ringer | 2017-04-22 01:14:50 | Re: multithreading in Batch/pipelining mode for libpq |