Re: Efficient use of ON CONFLICT DO UPDATE with the PostgreSQLJDBC driver - Mailing list pgsql-jdbc

From Vladimir Sitnikov
Subject Re: Efficient use of ON CONFLICT DO UPDATE with the PostgreSQLJDBC driver
Date
Msg-id CAB=Je-GOicmnV00aToC1Gvt4GMZBwj2psLO5AnQamK4b=-c1hA@mail.gmail.com
Whole thread Raw
In response to Re: [JDBC] Efficient use of ON CONFLICT DO UPDATE with the PostgreSQLJDBC driver  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc
>On the Java side, that means invoking PreparedStatement::setBinaryStream TWICE for the same data.


AFAIK, frontend-backend protocol allows to reuse $1 multiple times in the same query, so it seems to be indeed a bit efficient to use

values($1, $2, $3) on conflict.... set file_data=$1, file_name=$2

kind of query.

Obviously, you can use pl/pgsql procedure to workaround that. At least that would optimize network traffic.


AFAIK, JDBC references parameters by parameter position, so there's no implementation-independent way to reuse the same parameter without it sending it twice over the wire.


Vladimir

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: [JDBC] Efficient use of ON CONFLICT DO UPDATE with the PostgreSQLJDBC driver
Next
From: Christopher BROWN
Date:
Subject: Re: Efficient use of ON CONFLICT DO UPDATE with the PostgreSQLJDBC driver