MongoDb에서 Oracle 데이터베이스로 변경 사항을 지속적으로 내보내는 도구를 개발 중입니다.oracle 일반 문 대량 작업 속도를 높이는 방법?
실행 일괄 처리 작업 (Oracle)에 문제가 있습니다.
static void save(List result) {
withBatchConnection { Statement stm ->
result.each { String line ->
stm.addBatch(line)
}
}
}
static withConnection(Closure closure) {
def conn = null
boolean success = false
while (!success) {
try {
conn = getConnection()
closure.call(conn)
success = true
} catch (e) {
log.error('Connection problem', e)
log.error(e, e)
log.info('Retrying for 30 sec')
sleep(30000)
} finally {
conn?.close()
}
}
}
static withTransactionConnection(Closure closure) {
withConnection { Sql sql ->
OracleConnection conn = sql.getConnection() as OracleConnection
conn.setAutoCommit(false)
closure.call(conn)
conn.commit()
}
}
static withBatchConnection(Closure closure) {
withTransactionConnection { Connection conn ->
def statement = conn.createStatement()
closure.call(statement)
statement.executeBatch()
statement.close()
}
}
문제는 조작 순서가 매우 중요하기 때문에 준비된 문을 사용할 수 없습니다.
Rewrite Batch Statement를 사용하여 MySql에 저장할 때 초당 10k 작업이 발생합니다. 오라클이 400 작업/초일 경우
더 빨리 할 수 있습니까?
나는 OJDBC 7을 사용하고 있는데 그루비 2.4.7
오라클과 MySQL을 사이에 한 가지 중요한 차이점은 트랜잭션의 "커밋"단계에있다 오라클은 MySQL에 존재하지 않습니다. 당신이 관찰하는 것의 원천이 될 수 있습니다. 각 단계마다 데이터베이스에 커밋이 있습니까? 그렇다면이를 피하고 예를 들어 모든 것을 저지하십시오. 10000 업데이트. –
준비된 명령문과 작업 순서가 서로 어떤 관계가 있는지 알 수 없음 – john16384
연결에 자동 커밋이 기본적으로 '설정'되어 있는지 확인하십시오. 즉, 모든 명령문 이후 커밋을 의미합니다. – john16384