Here a snippet:
Properties props = new Properties();
props.put("user", "test1");
props.put("password", "test1");
Connection connection = java.sql.DriverManager.getConnection("jdbc:postgresql://<server>", props);
Statement st = connection.createStatement();
st.execute("CREATE TABLE TestClob1 (id int8 NOT NULL, data TEXT, PRIMARY KEY(id))");
st.close();
st = connection.createStatement();
st.execute("INSERT INTO TestClob1 (id) VALUES (1) ");
st.close();
st = connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
ResultSet resultSet = st.executeQuery("SELECT id, data FROM TestClob1 WHERE id = 1 ");
resultSet.next();
resultSet.updateCharacterStream(2, new StringReader("hello"), "hello".length());
resultSet.updateRow();
resultSet.close();
Da: Nicola Zanaga
Inviato: domenica 17 luglio 2016 11:39
A: pgsql-jdbc@postgresql.org
Oggetto: Slow performance updating CLOB data
Hi, using ResultSet.updateCharacterStream to update a CLOB is very slow.
Most of the time is spent in method PgResultSet.isUpdateable because the table has a primary key but doesn't have a "oid" column.
So the code tries to get primary keys from the query, using getMetaData().getPrimaryKeys.
This is a very slow process.
There is any workaround ?