Обсуждение: "another command is already in progress" error (fwd)

Поиск
Список
Период
Сортировка

"another command is already in progress" error (fwd)

От
pgsql@frenzy.org
Дата:
I am doing asynchronous sql calls using the postgres C library.
After doing two PQsendQuery() calls, I get the

"another command is already in progress" error.
The two calls I am doing are an update, and then an insert, in that order.
I am doing this for speed, since my program can't afford to wait for the
answer from the first to complete before making the request for the
second.

For some reason this method has started giving the error above, even
though it has been running on the same testing box for its entire
lifecycle and it wasn't before.

My two questions are:

1. Is there a way to get around this error besides doing some kind of busy
loop?

2. Is there a faster way of doing an update/insert than doing two
asynchronous requests? I want it to be as fast as possible. I was doing a
select first, then either an insert or an update depending on the entry
was there, but this method has speeded up our process by about 10x.

Thanks for the help, I've checked the archives, but am a new list member
myself, and hope to get to know postgresql more as time goes on.

Randy

http://www.frenzy.org
"Sed Quis Custodiet Ipsos Custodes?" -Juvenal

This communication (including any attachments) is intended for the use of the intended
recipient only and may contain information that is confidential, privileged or legally
protected. Any unauthorized use or dissemination of this communication is strictly
prohibited. If you have received this communication in error, please immediately notify
the sender by return e-mail message and delete all copies of the original communication.
Thank you for your cooperation.





Re: "another command is already in progress" error (fwd)

От
Tom Lane
Дата:
pgsql@frenzy.org writes:
> I am doing asynchronous sql calls using the postgres C library.
> After doing two PQsendQuery() calls, I get the
> "another command is already in progress" error.
> The two calls I am doing are an update, and then an insert, in that order.
> I am doing this for speed, since my program can't afford to wait for the
> answer from the first to complete before making the request for the
> second.
> For some reason this method has started giving the error above, even
> though it has been running on the same testing box for its entire
> lifecycle and it wasn't before.

I don't think I believe that; that has never been supported.

If you have several commands you'd like to fire off as a batch, you can
put them in a single PQsendQuery (with semicolons between of course).
Then keep reading PGresults until you get a NULL.  But you can't issue
another PQsendQuery until you've gotten that NULL.

At least, not on the same connection.  I'm not sure opening multiple
connections could be a win for you, but it might be something to think
about.

            regards, tom lane