Why is Camel JDBC so slow compare to Java JDBC? (1 Sec vs 4 Minutes)

197 Views Asked by At

I am using camel jdbc in place of simple java jdbc code just to fetch 10,200 records

Java JDBC:

Connection c = dataSource.getConnection();
        Statement m = c.createStatement();
        ResultSet rs = m.executeQuery(getEmployeeCall());
        while(rs.next()) {
            System.out.println(""+ rs.getString(1));
            break;
        }

Result comes just in 1 -2 seconds.

BUt when i use Camel JDBC:

.log(LoggingLevel.INFO, getEmployeeCall())
                    .setBody(constant(getEmployeeCall()))
                    .to("jdbc:masterdata")
                    .to("log:?level=INFO&showBody=true");

It took around 4 minutes to get results which is a lot.

Any idea why Camel JDBC is so slow?

Query looks somewhat like:

SELECT e.userid, e.firstname, e.lastname, e.mobilephone, e.email, e.employmenttype, e.enddate, decode(e.llevel,'','N','Y') as Manager, e.llevel, leader.userid as leader_userid, cm.companyname as cm_companyname, CASE e.companyid WHEN '1'  THEN '29' WHEN '13' THEN '435' WHEN '550' THEN '153' WHEN '640' THEN '52' WHEN '67' THEN '40' ELSE e.companyid END as companyid, e.COUNTRY, loc.LOCATIONNAME as loc_locationname, e.unitid, org.UNITNAME as org_unitname,  e.resultareaid as orgstr_unitid, e.locationid, e.imageprofile FROM employee e LEFT JOIN employee leader ON e.leaderemployeeid = leader.EMPLOYEEID LEFT JOIN company cm ON (CASE WHEN e.companyid = '1'  THEN '29' WHEN e.companyid = '13' THEN '435' WHEN e.companyid = '550' THEN '153' WHEN e.companyid = '60' THEN '52' WHEN e.companyid = '67' THEN '40' ELSE e.companyid END) = cm.companyid LEFT JOIN organisation org ON e.unitid = org.UNITID LEFT JOIN location loc ON e.locationid = loc.LOCATIONID WHERE (e.enddate is null or e.enddate > sysdate - 31)

Any idea to fix this in camel jdbc or shall i create bean for this purpose?

0

There are 0 best solutions below