Search Postgresql Archives

Re: PQisBusy() always returns TRUE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 15, 2005 at 09:50:35PM +0200, ntinos@xxxxxxx 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@xxxxxxxxx>   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.

Attachment: pgpKJX0k2SvLK.pgp
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux