非同步提交

psufnxk2000發表於2013-09-12
The default behavior. is for LGWR to write redo to the online redo log synchronously 
and for transactions to wait for the buffered redo to be on disk before returning a 
commit to the user. However, for lower transaction commit latency, application 
developers can specify that redo be written asynchronously so that transactions need 
not wait for the redo to be on disk and can return from the COMMIT  call immediately.
預設的lgwr寫是同步方式,事務等待redo buffer的資訊寫到磁碟才返回commit完成 ,這可能會造成commit效能低。
應用開發者可以指定非同步寫redo,這樣事務不必須等待redo寫到磁碟。

If you specify only COMMIT, then the default is COMMIT WORK WRITE WAIT IMMEDIATE.
如果只指定commit,預設使用的是 commit work write wait immediate
WORK
The WORK keyword is supported for compliance with standard SQL. The statements COMMIT and COMMIT WORK are equivalent.
work關鍵字是為了支援標準sql,commit 和 commit work是等價的

COMMENT Clause
This clause is supported for backward compatibility. Oracle recommends that you used named transactions instead of commit comments.
為了向後相容性,oracle建議使用命名的事務替代commit comment

WAIT | NOWAIT 
Use these clauses to specify when control returns to the user.
使用這個子句控制什麼時候返回給使用者
The WAIT parameter ensures that the commit will return only after the corresponding redo is persistent in the online redo log. Whether in BATCH or IMMEDIATE mode, when the client receives a successful return from this COMMIT statement, the transaction has been committed to durable media. A crash occurring after a successful write to the log can prevent the success message from returning to the client. In this case the client cannot tell whether or not the transaction committed.
用wait時,寫到磁碟之後,才會返回給使用者

The NOWAIT parameter causes the commit to return to the client whether or not the write to the redo log has completed. This behavior. can increase transaction throughput. With the WAIT parameter, if the commit message is received, then you can be sure that no data has been lost.
用nowait時,無論是否已經寫入到磁碟到,都會返回給使用者,增加了事務的吞吐量

IMMEDIATE | BATCH 
Use these clauses to specify when the redo is written to the log.
使用這個子句指定什麼時候寫到log檔案
The IMMEDIATE parameter causes the log writer process (LGWR) to write the transaction's redo information to the log. This operation option forces a disk I/O, so it can reduce transaction throughput.
使用immediate引數立即寫到線上日誌檔案,這個選項一定會有io產生,所以減少了事務的吞吐量
The BATCH parameter causes the redo to be buffered to the redo log, along with other concurrently executing transactions. When sufficient redo information is collected, a disk write of the redo log is initiated. This behavior. is called "group commit", as redo for multiple transactions is written to the log in a single I/O operation.
batch引數可以批量提交redo資訊到線上日誌檔案

如果您資料庫預設使用某種特定的提交行為,則可以執行以下語句。

ALTER SYSTEM SET COMMIT_WRITE = NOWAIT;

此命令將使資料庫預設使用這一行為。您還可以使其成為會話級預設行為:

ALTER SESSION SET COMMIT_WORK = NOWAIT;

注:不是預設方式的話有可能會丟失資料

by song 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25099483/viewspace-772646/,如需轉載,請註明出處,否則將追究法律責任。

相關文章