Hi Alexey, 

As Ilya suggested, setting walMode = BACKGROUND has brought performance into
the area of expected values. My code that populates Postgre is below. Thanks
a log for your reply.

public class PopulatePostgre {
        private static final char[] LETTERS = {'a', 'b', 'c', 'd', 'e', 'f', 
'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'x',
'y', 'z'};
        private static final int L_SIZE = LETTERS.length;
        
        public static void main(String argv[]) throws Exception {
                int idx0 = 0, idx1 = 0, idx2 = 0;
                StringBuilder bf = new StringBuilder();
                
                Class.forName("org.postgresql.Driver");
                try (Connection con =
DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres",
"postgres", "postgres")) {
                        con.setAutoCommit(false);
                        try (Statement st = con.createStatement()) {
                                st.execute("create table test(kkey varchar(10) 
primary key, val
varchar(200))");
                                con.commit();
                        }
                        
                        try (PreparedStatement pst = 
con.prepareStatement("insert into test(kkey,
val) values(?, ?)")) {
                                long start = System.currentTimeMillis();
                                for (int i = 0; i < 10000; i++) {
                                        bf.setLength(0);
                                        
bf.append(LETTERS[idx0]).append(LETTERS[idx1]).append(LETTERS[idx2]);
                                        
                                        if (++idx2 == L_SIZE) {
                                                idx2 = 0;
                                                if (++idx1 == L_SIZE) {
                                                        idx1 = 0;
                                                        if (++idx0 == L_SIZE) {
                                                                idx0 = 0;
                                                        }
                                                }
                                        }

                                        pst.setString(1, String.valueOf(i));
                                        pst.setString(2, bf.toString());
                                        pst.executeUpdate();
                                        con.commit();
                                }
                                long end = System.currentTimeMillis();
                                System.out.println("=== Execution time is " + 
(end - start) + " ms.");
                        }
                }
        }
}




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to