iBATIS 2.x 는 대량의 insert, update, delete 작업을 효율적으로 처리 할 수 있는 방법으로 startBatch(), executeBatch() 메서드를 제공한다.
개발자 가이드에 의하면 네트워크 트래픽 최소화, JDBC 드라이버의 추가적인 최적화(압축같은) 같은 혜택을 통해 성능향상을 볼 수 있다고 한다.
startBatch(), executeBatch() 메서드는 문서상으로 명시적 transaction 과 함께 사용해야 한다고 나오지는 않았으나
테스트시에는 명시적 transaction 을 사용하지 않았을때는 일반작업과 동일하거나 나쁜 결과를 보였다.
1. 특징
UPDATE 문 1000번 반복 처리 속도 테스트 결과
1) 배치+트랜잭션 : 77ms
2) 트랜잭션 : 1104ms
3) 일반작업 : 4274ms
4) 배치 : 4604ms
다음은 "UPDATE Computers SET ..." 문을 배치로 10번 실행하는 부분의 디버그 로그다.
DEBUG [23:14:02.230] {Timer-4} (Log4jImpl.java:26) Checked out connection 30587319 from pool.
DEBUG [23:14:02.236] {Timer-4} (Log4jImpl.java:26) {conn-100030} Connection
DEBUG [23:14:02.246] {Timer-4} (Log4jImpl.java:26) {conn-100030} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:14:02.276] {Timer-4} (Log4jImpl.java:26) Returned connection 30587319 to pool.
그리고 다음은 같은 UPDATE 문을 배치하지 않고 트랜잭션만 걸린 상태로 10번 실행한 부분의 디버그 로그다.
DEBUG [23:18:24.438] {Timer-4} (Log4jImpl.java:26) Checked out connection 2987443 from pool.
DEBUG [23:18:24.447] {Timer-4} (Log4jImpl.java:26) {conn-100030} Connection
DEBUG [23:18:24.454] {Timer-4} (Log4jImpl.java:26) {conn-100030} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.461] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.467] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9999, 9999, BIOS_0fb9d04cdf4cdd25c1d9cde75882762e, null, null, TEST, TEST, TEST, null, null, 100100]
DEBUG [23:18:24.471] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.479] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.485] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9998, 9998, BIOS_0fb9d04cdf4cdd25c1d9cde75882762r, null, null, TEST, TEST, TEST, null, null, 100101]
DEBUG [23:18:24.490] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.497] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.504] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9997, 9997, BIOS_0fb9d04cdf4cdd25c1d9cde75882762t, null, null, TEST, TEST, TEST, null, null, 100102]
DEBUG [23:18:24.508] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.515] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.521] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9996, 9996, BIOS_0fb9d04cdf4cdd25c1d9cde75882762y, null, null, TEST, TEST, TEST, null, null, 100103]
DEBUG [23:18:24.526] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.534] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.541] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9995, 9995, BIOS_0fb9d04cdf4cdd25c1d9cde75882762u, null, null, TEST, TEST, TEST, null, null, 100104]
DEBUG [23:18:24.546] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.553] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.559] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9994, 9994, BIOS_0fb9d04cdf4cdd25c1d9cde75882762g, null, null, TEST, TEST, TEST, null, null, 100105]
DEBUG [23:18:24.563] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.571] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.575] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9993, 9993, BIOS_0fb9d04cdf4cdd25c1d9cde75882762z, null, null, TEST, TEST, TEST, null, null, 100106]
DEBUG [23:18:24.579] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.592] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.597] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9992, 9992, BIOS_0fb9d04cdf4cdd25c1d9cde75882762x, null, null, TEST, TEST, TEST, null, null, 100107]
DEBUG [23:18:24.602] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.606] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.610] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9991, 9991, BIOS_0fb9d04cdf4cdd25c1d9cde75882762v, null, null, TEST, TEST, TEST, null, null, 100108]
DEBUG [23:18:24.613] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.617] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:18:24.622] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9990, 9990, BIOS_0fb9d04cdf4cdd25c1d9cde75882762c, null, null, TEST, TEST, TEST, null, null, 100109]
DEBUG [23:18:24.625] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:18:24.643] {Timer-4} (Log4jImpl.java:26) Returned connection 2987443 to pool.
배치 적용 유무에 따른 속도 차이는 상황에 따라 많이 다르지만 위 테스트에선 대략 5~7배 정도 차이를 보였다.
위 테스트에서 트랜잭션까지 빼면 디버그 로그는 다음과 같이 나온다.
DEBUG [23:24:34.529] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.537] {Timer-4} (Log4jImpl.java:26) {conn-100030} Connection
DEBUG [23:24:34.543] {Timer-4} (Log4jImpl.java:26) {conn-100030} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.549] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.555] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Parameters: [9999, 9999, BIOS_0fb9d04cdf4cdd25c1d9cde75882762e, null, null, TEST, TEST, TEST, null, null, 100100]
DEBUG [23:24:34.558] {Timer-4} (Log4jImpl.java:26) {pstm-100031} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.568] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.573] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.577] {Timer-4} (Log4jImpl.java:26) {conn-100032} Connection
DEBUG [23:24:34.582] {Timer-4} (Log4jImpl.java:26) {conn-100032} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.587] {Timer-4} (Log4jImpl.java:26) {pstm-100033} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.591] {Timer-4} (Log4jImpl.java:26) {pstm-100033} Parameters: [9998, 9998, BIOS_0fb9d04cdf4cdd25c1d9cde75882762r, null, null, TEST, TEST, TEST, null, null, 100101]
DEBUG [23:24:34.597] {Timer-4} (Log4jImpl.java:26) {pstm-100033} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.615] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.618] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.624] {Timer-4} (Log4jImpl.java:26) {conn-100034} Connection
DEBUG [23:24:34.626] {Timer-4} (Log4jImpl.java:26) {conn-100034} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.639] {Timer-4} (Log4jImpl.java:26) {pstm-100035} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.649] {Timer-4} (Log4jImpl.java:26) {pstm-100035} Parameters: [9997, 9997, BIOS_0fb9d04cdf4cdd25c1d9cde75882762t, null, null, TEST, TEST, TEST, null, null, 100102]
DEBUG [23:24:34.654] {Timer-4} (Log4jImpl.java:26) {pstm-100035} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.674] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.681] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.686] {Timer-4} (Log4jImpl.java:26) {conn-100036} Connection
DEBUG [23:24:34.694] {Timer-4} (Log4jImpl.java:26) {conn-100036} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.703] {Timer-4} (Log4jImpl.java:26) {pstm-100037} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.710] {Timer-4} (Log4jImpl.java:26) {pstm-100037} Parameters: [9996, 9996, BIOS_0fb9d04cdf4cdd25c1d9cde75882762y, null, null, TEST, TEST, TEST, null, null, 100103]
DEBUG [23:24:34.714] {Timer-4} (Log4jImpl.java:26) {pstm-100037} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.735] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.739] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.749] {Timer-4} (Log4jImpl.java:26) {conn-100038} Connection
DEBUG [23:24:34.753] {Timer-4} (Log4jImpl.java:26) {conn-100038} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.760] {Timer-4} (Log4jImpl.java:26) {pstm-100039} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.765] {Timer-4} (Log4jImpl.java:26) {pstm-100039} Parameters: [9995, 9995, BIOS_0fb9d04cdf4cdd25c1d9cde75882762u, null, null, TEST, TEST, TEST, null, null, 100104]
DEBUG [23:24:34.769] {Timer-4} (Log4jImpl.java:26) {pstm-100039} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.784] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.787] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.793] {Timer-4} (Log4jImpl.java:26) {conn-100040} Connection
DEBUG [23:24:34.796] {Timer-4} (Log4jImpl.java:26) {conn-100040} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.801] {Timer-4} (Log4jImpl.java:26) {pstm-100041} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.806] {Timer-4} (Log4jImpl.java:26) {pstm-100041} Parameters: [9994, 9994, BIOS_0fb9d04cdf4cdd25c1d9cde75882762g, null, null, TEST, TEST, TEST, null, null, 100105]
DEBUG [23:24:34.810] {Timer-4} (Log4jImpl.java:26) {pstm-100041} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.838] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.842] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.848] {Timer-4} (Log4jImpl.java:26) {conn-100042} Connection
DEBUG [23:24:34.851] {Timer-4} (Log4jImpl.java:26) {conn-100042} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.855] {Timer-4} (Log4jImpl.java:26) {pstm-100043} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.861] {Timer-4} (Log4jImpl.java:26) {pstm-100043} Parameters: [9993, 9993, BIOS_0fb9d04cdf4cdd25c1d9cde75882762z, null, null, TEST, TEST, TEST, null, null, 100106]
DEBUG [23:24:34.866] {Timer-4} (Log4jImpl.java:26) {pstm-100043} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:34.889] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:34.892] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:34.896] {Timer-4} (Log4jImpl.java:26) {conn-100044} Connection
DEBUG [23:24:34.900] {Timer-4} (Log4jImpl.java:26) {conn-100044} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.905] {Timer-4} (Log4jImpl.java:26) {pstm-100045} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:34.962] {Timer-4} (Log4jImpl.java:26) {pstm-100045} Parameters: [9992, 9992, BIOS_0fb9d04cdf4cdd25c1d9cde75882762x, null, null, TEST, TEST, TEST, null, null, 100107]
DEBUG [23:24:35.009] {Timer-4} (Log4jImpl.java:26) {pstm-100045} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:35.057] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:35.082] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:35.114] {Timer-4} (Log4jImpl.java:26) {conn-100046} Connection
DEBUG [23:24:35.146] {Timer-4} (Log4jImpl.java:26) {conn-100046} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:35.183] {Timer-4} (Log4jImpl.java:26) {pstm-100047} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:35.206] {Timer-4} (Log4jImpl.java:26) {pstm-100047} Parameters: [9991, 9991, BIOS_0fb9d04cdf4cdd25c1d9cde75882762v, null, null, TEST, TEST, TEST, null, null, 100108]
DEBUG [23:24:35.215] {Timer-4} (Log4jImpl.java:26) {pstm-100047} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:35.255] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
DEBUG [23:24:35.259] {Timer-4} (Log4jImpl.java:26) Checked out connection 31344098 from pool.
DEBUG [23:24:35.265] {Timer-4} (Log4jImpl.java:26) {conn-100048} Connection
DEBUG [23:24:35.275] {Timer-4} (Log4jImpl.java:26) {conn-100048} Preparing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:35.283] {Timer-4} (Log4jImpl.java:26) {pstm-100049} Executing Statement: UPDATE Computers SET employeeSeq = decode(?, '0', employeeSeq, null, employeeSeq, ?) , computerGUID = nvl(?, computerGUID) , installDate = nvl(?, installDate) , lastUpdate = nvl(?, lastUpdate) , macAddress = nvl(?, macAddress) , ipAddress = nvl(?, ipAddress) , agentVersion = nvl(?, agentVersion) , useSeq = nvl(?, useSeq) , uninstallDate = nvl(?, uninstallDate) WHERE computerSeq = ?
DEBUG [23:24:35.291] {Timer-4} (Log4jImpl.java:26) {pstm-100049} Parameters: [9990, 9990, BIOS_0fb9d04cdf4cdd25c1d9cde75882762c, null, null, TEST, TEST, TEST, null, null, 100109]
DEBUG [23:24:35.294] {Timer-4} (Log4jImpl.java:26) {pstm-100049} Types: [java.lang.Integer, java.lang.Integer, java.lang.String, null, null, java.lang.String, java.lang.String, java.lang.String, null, null, java.lang.Integer]
DEBUG [23:24:35.302] {Timer-4} (Log4jImpl.java:26) Returned connection 31344098 to pool.
위 테스트는 트랜잭션만 건 테스트에 비해 3-5배정도 느리게 나왔다.
트랜잭션없이 배치만 걸면 위 테스트와 비슷하거나 더 느린 결과를 보였다.
2. 장점
동일유형의 작업을 빠르게 처리 한다. 테스트시 최대 50배이상 빠르게 실행되는 경우도 있었다.
3. 단점
작업실패시 모든 배치가 롤백된다.
- 롤백하지 않고 실패한건만 무시하고 계속 진행하고 싶은 경우엔 해결 방법이 없다.
문제가 발생했을때 어디서 발생했는지 알기 어렵다.
- executeBatch() 메서드는 성공한 업데이트 수를 반환한다. 단, insert, update, delete 에 한한다.queryForObject 의 수행결과는 알 수 없다
- executeBatchDetail() 메서드는 더욱 상세한 모든 배치작업결과를 반환한다. 하지만 역시 insert, update, delete 에 한한다.
- 또 작업중 예외가 발생하면 배치예외를 던지는데, 어떤 문장(statement)에서 예외가 발생했는지는 보이지만 동일한 문장을 배치작업으로 여러개 수행하는 경우라면 어느 부분에 문제가 발생했는지 알 수 없다.
위와같은 한계로 배치 중 오류발생시 무시하고 다음으로 진행하고 싶을땐 배치할 작업을 저장해두고 있다가 예외를 잡아 일반작업으로 넘겨 처리해줘야 하는 불편이 있다.
※ 배치예외, 배치결과객체 분석이 충분하지 않아 단점으로 지적한 부분에 문제가 있을수도 있다.
*4. 결론*
동일작업을 대량 반복할때 배치, 트랜잭션은 성능을 대폭 향상시킨다.
배치예외가 빈번히 발생하는게 아니라면, 예외시 일반작업 처리를 위한 대비 코드를 사용하는 비용을 치르더라도 배치를 쓰는게 좋다.
'IT > Java' 카테고리의 다른 글
[iBATIS 2.x] insert 성공 여부 판단 (0) | 2010.11.18 |
---|---|
[iBATIS 2.x] 트랜잭션 동시성 문제 있을까? (0) | 2010.11.16 |
Java Tip #2 : 큐(Queue) 성능 테스트 (1) | 2010.11.09 |
Spring - iBATIS : 웹서버 시작시 jdbc.properties 를 읽지 못해도 무시하게 하자 (0) | 2010.07.14 |
Spring - iBATIS : dataSource 의 동적 로딩 (2) | 2010.07.14 |