Re: Libpq single-row mode slowness

2022-05-01 Thread Daniele Varrazzo
On Sun, 1 May 2022 at 23:12, Tom Lane wrote: > The usual expectation is that you call PQconsumeInput to get rid of > a read-ready condition on the socket. If you don't have a poll() or > select() or the like in the loop, you might be wasting a lot of > pointless recvfrom calls. You definitely d

Re: Libpq single-row mode slowness

2022-05-01 Thread Tom Lane
Daniele Varrazzo writes: > The operations we perform, for every row, are PQconsumeInput, > PQisBusy, PQgetResult. Every PQconsumeInput results in a recvfrom() > syscall, of which the first one returns the whole recordset, the > following ones return EAGAIN. There are two extra cycles: one to get >

Libpq single-row mode slowness

2022-05-01 Thread Daniele Varrazzo
Hello, a Psycopg 3 user has tested what boils down pretty much to a "generate_series(100K)" and has reported a 100x difference between fetching it normally and in single-row mode. I have repeated the test myself and I have found a 50x difference (the OP doesn't specify which platform is using, min