Pivotal Greenplum 6.0.0 batch insert

Posted by degeorge on 09-Sep-2019 08:50

I had Pivotal GP 6.0.0 version and DataDirect JDBC driver 5.1.4 distributed by pivotal. When i trying to use batch inserts via jdbc, rows are sending one by one as separate single inserts. Wireshark shows that for each addBatch method driver creates new bind and execute postgres protocol instructions then database response with bind completion and command completion (Tag: INSERT 0 1) for each row. So it is how single inserts work.

Simple java code:

Connection connection = DriverManager.getConnection(url, props);
connection.setAutoCommit(false);
String sql = "INSERT INTO test VALUES (?)";
PreparedStatement statement = connection.prepareStatement(sql);
int batchSize = 1000; 
Random random = new Random();
for (int i = 0; i < batchSize; i++) {
    long ts = random.nextLong();
    statement.setLong(1, ts);
    statement.addBatch();
}
statement.executeBatch();
connection.commit();


So the question is - does this is expected behavior and batch inserts not working or i must use driver in another way?

All Replies

This thread is closed