From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | ntinos(at)aueb(dot)gr |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: PQisBusy() always returns TRUE |
Date: | 2005-01-15 20:28:19 |
Message-ID: | 20050115202758.GD22775@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, Jan 15, 2005 at 09:50:35PM +0200, ntinos(at)aueb(dot)gr wrote:
> If understand correctly what you are saying, the right code for this thing
> is:
>
> PQconsumeInput(conn); //Try to collect the results
> while (PQisBusy(conn)) // while not ready ...
> PQconsumeInput(conn); //...retry
>
> res=PQgetResult(conn); // Now get the results
>
> I tried this and it worked. However, the problem now is that it is slow
> (surely slower than using blocking commands).
> If the code above is right (?), why is that?
The purpose of non-blocking commands is so you can do something else
useful in the meantime. The above is probably slower because you're
using all your CPU time spinning in a loop.
I belive if you're waiting in an event loop, you can use PQsocket() to
return the fd to use in select. Or if you're doing other work, do that
while you're waiting and check isBusy when you have time...
Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | Edmund Dengler | 2005-01-15 21:00:03 | Multi-column indexes |
Previous Message | Martijn van Oosterhout | 2005-01-15 20:23:31 | Re: OID Usage |