metamodel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laxmi Lal Menaria <menarialaxmi...@gmail.com>
Subject Best way to use RowInsertBuilder with Millions of insert query
Date Thu, 18 Oct 2018 04:21:32 GMT
Hello Everyone,

I have created a sample which insert data from csv to SQL table, I used
RowInsertBuilder with BatchUpdateScript, it is working fine but takes too
much time to complete the operation because we have millions of rows in
csv.

I would need a better way to speedup the process, please let me know how
can I improve it, i.e. close the PreparedStatement after 10k rows or
something else, so few thousands rows  executed and it will free up the
list.

Current code block is:

final UpdateableDataContext dc = con.getUpdateableDataContext();
        dc.executeUpdate((BatchUpdateScript) callback -> {
            for (final Object[] rowData : buffer) {
                RowInsertionBuilder insertBuilder =
callback.insertInto(columns[0].getTable());
                for (int i = 0; i < columns.length; i++) {
                    insertBuilder = insertBuilder.value(columns[i],
rowData[i]);
                }
                try {
                    insertBuilder.execute();

                } catch (final RuntimeException e) {

                }
            }
});

-- 

Thanks,
Laxmilal Menaria | +91 982 955 3793 | http://laxmilalmenaria.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message