[ https://issues.apache.org/jira/browse/FLINK-34901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17846235#comment-17846235 ]
ouyangwulin commented on FLINK-34901: ------------------------------------- Some versions of pgsql also give this error: {code:java} //ERROR: modification of distribution columns in OnConflictUpdate is not supported Call getNextException to see other errors in the batch. at org.postgresql.jdbc.BatchResultHandler.handleCompletion(BatchResultHandler.java:186) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:878) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:916) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1684) ~[postgresql-42.5.4.jar:42.5.4] at org.apache.flink.connector.jdbc.statement.FieldNamedPreparedStatementImpl.executeBatch(FieldNamedPreparedStatementImpl.java:65) ~[flink-connector-jdbc-3.1.2-1.18.jar:3.1.2-1.18] at org.apache.flink.connector.jdbc.internal.executor.TableSimpleStatementExecutor.executeBatch(TableSimpleStatementExecutor.java:64) ~[flink-connector-jdbc-3.1.2-1.18.jar:3.1.2-1.18] at org.apache.flink.connector.jdbc.internal.executor.TableBufferReducedStatementExecutor.executeBatch(TableBufferReducedStatementExecutor.java:101) ~[flink-connector-jdbc-3.1.2-1.18.jar:3.1.2-1.18] at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.attemptFlush(JdbcOutputFormat.java:246) ~[flink-connector-jdbc-3.1.2-1.18.jar:3.1.2-1.18] at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:216) ~[flink-connector-jdbc-3.1.2-1.18.jar:3.1.2-1.18] at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.writeRecord(JdbcOutputFormat.java:195) ~[flink-connector-jdbc-3.1.2-1.18.jar:3.1.2-1.18] ... 15 more Caused by: org.postgresql.util.PSQLException: ERROR: modification of distribution columns in OnConflictUpdate is not supported at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:316) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:874) ~[postgresql-42.5.4.jar:42.5.4] at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:916) ~[postgresql-42.5.4.jar:42.5.4] at org. {code} > Improve the performance of the update Postgres database > ------------------------------------------------------- > > Key: FLINK-34901 > URL: https://issues.apache.org/jira/browse/FLINK-34901 > Project: Flink > Issue Type: Improvement > Components: Connectors / JDBC > Reporter: ouyangwulin > Priority: Minor > Labels: pull-request-available > > When writing Postgres data using flinker-connector-jdbc, using upsert mode, > we need only update no uniqueColumns to improve performance. > > Whether you can modify the code is as follows: > String updateClause = > > {code:java} > Arrays.stream(fieldNames) > .filter(fieldName -> !Arrays.asList(uniqueKeyFields).contains(fieldName)) > .map(f -> quoteIdentifier(f) + "=EXCLUDED." + quoteIdentifier(f)) > .collect(Collectors.joining(", "));{code} -- This message was sent by Atlassian Jira (v8.20.10#820010)