By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,933 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,933 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
pg***@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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #2

P: n/a
pg***@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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.