Re: Should PQconsumeInput/PQisBusy be expensive to use? - Mailing list pgsql-general

From David Wilson
Subject Re: Should PQconsumeInput/PQisBusy be expensive to use?
Date
Msg-id AANLkTikNS5XAEYf_eAc-xcfyW0rw33xfZ4G-TsppHDXn@mail.gmail.com
Whole thread Raw
In response to Should PQconsumeInput/PQisBusy be expensive to use?  (Michael Clark <codingninja@gmail.com>)
List pgsql-general


On Wed, Oct 27, 2010 at 5:02 PM, Michael Clark <codingninja@gmail.com> wrote:

    while ( ((consume_result = PQconsumeInput(self.db)) == 1) && ((is_busy_result = PQisBusy(self.db)) == 1) )
        ;
    

The problem with this code is that it's effectively useless as a test. You're just spinning in a loop; if you don't have anything else to be doing while waiting for responses, then this sort of calling pattern is always going to be worse than just blocking.

Only do async if you actually have an async problem, and only do a performance test on it if you're actually doing a real async test, otherwise the results are fairly useless.

--
- David T. Wilson
david.t.wilson@gmail.com

pgsql-general by date:

Previous
From: Alex Hunsaker
Date:
Subject: Re: Should PQconsumeInput/PQisBusy be expensive to use?
Next
From: Tom Lane
Date:
Subject: Re: Should PQconsumeInput/PQisBusy be expensive to use?