javaperformanceeclipse-scout

Eclipse scout performance


Good morning, I'm using Scout Java version framework, with Oracle Java 17 e Tomcat 9.0.70 on Debian 11, when populating tables, TablePage, with many rows, 10,000-50,000 or more, from Postgresql database, cpu usage by Java, exceeds 100% and execution is slow.

I've made many attempts to optimize both Java and Tomcat with little success.

With ScoutJS, do I solve the problem? Or at least get a performance boost?

Any suggestions are welcome.

Thanks for the attention.


Solution

  • The SqlService helper classes use reflection a lot. This is why they can be very inefficient in these cases. I gained a ~70% time improvement by changing from

            SQL.selectInto(sqlString, new NVPair("page", pageData));
    

    to

            Object[][] result = SQL.select(sqlString);
            for (Object[] line : result) {
                PersonTableRowData row = new PersonTableRowData();
                if (line[0]!=null) row.setId((Long)line[0]);
                if (line[1]!=null) row.setName((String)line[1]);
                if (line[2]!=null) row.setPhone((String)line[2]);
                // ....
    
                pageData.addRow(row);
            }
    

    Of course you loose flexibility here, like when changing the model you also have to your code here.