ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bing Zou <xiguamaill...@gmail.com>
Subject Am I doing anything wrong? iBATIS has very poor performance on batch inserts compared to JDBC.
Date Thu, 09 Jun 2005 17:27:19 GMT
Am I doing anything wrong? Why iBATIS is so slow compared to JDBC?
Thanks.
---------------------------------------------------------------------------------------------------------
Using iBATIS to insert 1000 records: (38375 ms)
            sqlMap.startBatch();
            Map args = CollectionUtil.createMap(2);
            for(int i=0;i<p_resultList.size();i++){
                AdvancedSearchResultData resultData =
(AdvancedSearchResultData)p_resultList.get(i);
                args.put("RESULT_DATA", resultData);
                args.put("UserIdentifier", p_userID);
                sqlMap.insert("insertIntoTempTable", args);
            }
            sqlMap.executeBatch();

        INSERT INTO TEMPTABLE (ORDER_NUMBER, RESOURCE_ID,
RESOURCE_TYPE_ID,USER_ID, ATTACHMENT_ID)
        VALUES ( #RESULT_DATA.relevance#,
                 #RESULT_DATA.resourceIdentifier.ID#, 
                 4, 
                 #UserIdentifier.ID#,
                 #RESULT_DATA.attachmentIdentifier.ID# )

---------------------------------------------------------------------------------------------------------
Using JDBC to insert the same 1000 records (391 ms)
            statement = connection.prepareStatement( ""INSERT INTO
TEMP_FTS(ORDER_NUMBER,  RESOURCE_ID,
RESOURCE_TYPE_ID,USER_ID,ATTACHMENT_ID) " +
        "VALUES ( ?,?, 4, ?, ?)" );
            for(int i=0;i<p_resultList.size();i++){
            
                AdvancedSearchResultData resultData =
(AdvancedSearchResultData)p_resultList.get(i);
                statement.setLong( 1, i );
                statement.setLong( 2, resultData.getResourceId() ); 
                statement.setLong( 3, p_userID.getID() );
                statement.setLong( 4, resultData.getAttachmentId() );
// attachment_id
                statement.addBatch();
            }
            statement.executeBatch();

Mime
View raw message