Re: PQisBusy() always returns TRUE

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: PQisBusy() always returns TRUE
Дата
Msg-id 20050115202758.GD22775@svana.org
обсуждение исходный текст
Ответ на Re: PQisBusy() always returns TRUE  (ntinos@aueb.gr)
Ответы Re: PQisBusy() always returns TRUE
Список pgsql-general
On Sat, Jan 15, 2005 at 09:50:35PM +0200, ntinos@aueb.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@svana.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.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: OID Usage
Следующее
От: Edmund Dengler
Дата:
Сообщение: Multi-column indexes