i want to populate the data base table with more than 500 million lines, and i have the below insert method:
public void insertRecord(Record rec) throws SQLException, ClassNotFoundException {
if (this.isTableExists(this.TABLE_NAME)) {
Connection conn = this.getConnection();
conn.setAutoCommit(true);
PreparedStatement ps = conn.prepareStatement("insert into "+this.TABLE_NAME+" ("+this.NODE_ID_COL+", "+this.LAT_COL+", "+this.LNG_COL+", "+this.XML_PATH_COL+") values (?, ?, ?, ?)");
ps.setString(1, rec.getNodeID());
ps.setString(2, rec.getLat());
ps.setString(3, rec.getLng());
ps.setString(4, rec.getPath());
ps.addBatch();
ps.executeBatch();
ps.close();
conn.close();
} else {
Log.e(TAG, "insertRecord", "table: ["+this.TABLE_NAME+"] does not exist");
}
}
my question is, since i will insert huge number of lines, 1-should i use threads in the above posted method?
2-what is the best practie for such situation?
3-is ExecutorService yields petter performance in such situation?
Aucun commentaire:
Enregistrer un commentaire