Re: libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
On Thu, 26 Oct 2023, 00:10 Jelte Fennema, wrote: > On Wed, 25 Oct 2023 at 18:54, Daniele Varrazzo > wrote: > > - connect_timeout > > - multiple host, hostaddr, port > > - load_balance_hosts=random > > > > Does this list sound complete? > > I think you'd

Re: libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
On Wed, 25 Oct 2023 at 17:35, Jelte Fennema wrote: > Another approach is to use tcp_user_timeout instead of connect_timeout > to skip non-responsive hosts. It's not completely equivalent though to > connection_timeout though, since it also applies when the connection > is actually being used.

Re: libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
On Wed, 25 Oct 2023 at 17:35, Jelte Fennema wrote: > You should implement load_balance_hosts=random though > by randomizing your hosts list. Good catch. So it seems that, if someone wants to build an equivalent an async version of PQconnectdb, they need to handle on their own: -

libpq async connection and multiple hosts

2023-10-25 Thread Daniele Varrazzo
Hello, We are aware that, using async connection functions (`PQconnectStart`, `PQconnectPoll`), the `connect_timeout` parameter is not supported; this is documented at https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PQCONNECTSTARTPARAMS """ The connect_timeout connection

Re: [PoC] Federated Authn/z with OAUTHBEARER

2023-05-23 Thread Daniele Varrazzo
On Sat, 20 May 2023 at 00:01, Jacob Champion wrote: > - Some clients in the wild (psycopg2/psycopg) suppress all notifications > during PQconnectPoll(). If there is anything we can improve in psycopg please reach out. -- Daniele

$1 IS NULL with unknown type

2022-11-21 Thread Daniele Varrazzo
Hello, The operator `IS NULL` doesn't work if the argument has unknown type. In psycopg 3: >>> conn.execute("select %s is null", ['foo']).fetchone() IndeterminateDatatype: could not determine data type of parameter $1 This can get in the way of using the unknown type for strings (but

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

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,

Is it safe to use the extended protocol with COPY?

2021-09-01 Thread Daniele Varrazzo
Hello, in psycopg 3 we are currently using PQexecParams - although with no params - to send COPY commands. The reason is mostly to avoid people to send COPY together with other statements. Especially if other operations are chained after COPY: we would only notice them after copy is finished.

Re: Is a connection max lifetime useful in a connection pool?

2021-02-21 Thread Daniele Varrazzo
On Sun, 21 Feb 2021 at 19:12, Pavel Stehule wrote: > I have very strong experience - it is very useful. On Sun, 21 Feb 2021 at 19:26, Stephen Frost wrote: > Short answer- yes. Sounds good. Thank you very much for your insight! -- Daniele

Is a connection max lifetime useful in a connection pool?

2021-02-21 Thread Daniele Varrazzo
Hello, I am designing and implementing a connection pool for psycopg3 [1][2]. Some of the inspiration is coming from HikariCP [3], a Java connection pool. One of the HikariCP configuration parameters is "maxLifetime", whose description is: "This property controls the maximum lifetime of a

Types info on binary copy

2021-01-05 Thread Daniele Varrazzo
Hello, The PGresult structure returned on COPY ... FROM provides a handful of information (https://www.postgresql.org/docs/13/libpq-copy.html): number of fields expected and whether they are binary or not. However it doesn't provide the types expected. For binary copy the exact type is

Use of pager, help, localization:

2018-10-15 Thread Daniele Varrazzo
>From psql/help.c /* * Keep this line count in sync with the number of lines printed below! * Use "psql --help=variables | wc" to count correctly; but notice that * Windows builds currently print one more line than non-Windows builds. * Using the larger number is fine. */