oracle中dbms
并發 (Concurrency)
The ability of a database system which handles simultaneously or a number of transactions by interleaving parts of the actions or the overlapping this is called concurrency of the system.
數據庫系統通過交織部分操作或重疊操作來同時處理或處理大量事務的能力稱為系統并發性。
并發優勢 (Advantages of concurrency)
The good is to serve many users and provides better throughput by sharing resources.
這樣做的好處是可以為許多用戶提供服務,并通過共享資源提供更好的吞吐量。
Reduced waiting time response time or turn around time.
減少等待時間的響應時間或周轉時間。
Increased throughput or resource utilization
吞吐量或資源利用率提高
If we run only one transaction at a time than the acid property is sufficient but it is possible that when multiple transactions are executed concurrently than database may become inconsistent.
如果我們一次只運行一個事務,那么酸屬性就足夠了,但是當同時執行多個事務時,數據庫可能會變得不一致。
Overlapping with the input-output activity with CPU also makes the response time better.
與CPU的輸入輸出活動重疊也可以提高響應時間。
But interleaving of instruction between transaction may also lead to many problems due to which concurrency control is required.
但是事務之間的指令交織也可能導致許多問題,由于這些問題需要并發控制。
并發問題 (Problems due to concurrency)
There are many which may occur due to concurrency,
由于并發,可能發生許多情況,
1) Dirty read problem
1)臟讀問題
If a transaction reads an uncommitted temporary value written by some other transaction than it is called dirty read problem. In this one transaction read a data item updated by another uncommitted transaction that may be future be aborted or failed. In such cases, the read value disappears from the database upon abort this is turned on dirty read the reading transaction end with incorrect results.
如果一個事務讀取了由其他事務寫入的未提交的臨時值,則稱為臟讀取問題。 在此事務中,讀取由另一個未提交的事務更新的數據項,該數據項將來可能會中止或失敗。 在這種情況下,讀取值在中止時會從數據庫中消失,這將導致臟讀取中的讀取事務結束,并且結果不正確。
Example
例
T1 T2
R(A)
W(A)
R(A)
The values of item x which is read by T2 is called dirty read data because this data can be created by a transactions that has not been committed yet.
T2讀取的項x的值稱為臟讀取數據,因為該數據可以由尚未提交的事務創建。
2) Loss update problem/ write - write problem
2)丟失更新問題/寫-寫問題
This problem occur when two transactions access the same data item and have their operations interleaved in a way that makes the value of some database items incorrect.
當兩個事務訪問相同的數據項并以某種使某些數據庫項的值不正確的方式交錯操作時,會發生此問題。
If there are two write operations of the different transaction on some data values and in between them there are no read operations then the second write over the first .consider the schedule below,
如果不同事務在某些數據值上有兩次寫操作,并且在它們之間沒有讀操作,則在第一個上進行第二次寫操作。請考慮以下時間表,
Example
例
T1 T2
R(A)
W(A)
W(A)
Here is a blind write that means write without a read. Here the changes made by transaction T1 are lost which is updated by a transaction T2.
這是盲寫,表示寫而沒有讀。 此處,事務T1所做的更改會丟失,而事務T2會對其進行更新。
3) Unrepeatable and phantom read problem
3)不可重復的幻像讀取問題
When a transaction cannot repeat the read instructions because the variable is deleted by some other transaction then this problem is called phantom read problem. In this problem at different instances of time a transaction read gives different values it is because data item might have been updated by another transaction.
當某個事務由于該變量被其他事務刪除而無法重復讀取指令時,此問題稱為幻像讀取問題。 在此問題中,在不同的時間實例下,事務讀取給出不同的值是因為數據項可能已被另一個事務更新。
This causes a problem while execution of some aggregate by a transaction and due to changes in the values of the data item by another transaction it leads to incorrect results. When a transaction read values of data item twice and another transaction's updates data item in between then the results of two read operations will differ.
這在事務執行某些聚合時會引起問題,并且由于另一事務在數據項的值更改中會導致錯誤的結果。 當一個事務兩次讀取數據項的值,而在兩次事務之間更新另一個數據項的更新時,兩次讀取操作的結果將有所不同。
Example
例
T1 T2
R(A)
R(A)
Delete(A)
R(A)
4) Incorrect summary problem
4)錯誤的匯總問題
When one of the transactions is checking on aggregate summary function while other transactions are updating then this problem is called incorrect summary problem. The aggregate functions may calculate some values before they updated and others after they are updated.
當其中一個事務正在檢查匯總摘要功能而其他事務正在更新時,此問題稱為不正確的摘要問題。 聚合函數可以在更新之前計算某些值,而在更新之后計算其他值。
時間表 (Schedule)
A schedule contains two or more transaction or one after another. All the instructions of each individual transaction will appear in the schedule contact switching can be done but we cannot change the order of execution.
時間表包含兩個或多個事務或一個接一個。 每個交易的所有指令都將出現在時間表中,可以進行聯系切換,但是我們不能更改執行順序。
時間表類型 (Types of schedule )
Schedule can be classified into mainly two types,
時間表主要可以分為兩種類型,
Serial schedule
序列時間表
if the schedule runs only one transaction at a time and can start other transaction after computing the first than it is called serial schedule. If there are n schedules than ! n different schedules are possible.
如果計劃一次僅運行一個事務,并且可以在計算第一個事務之后啟動另一個事務,則稱為串行計劃。 如果有n個時間表,則比! n可能有不同的時間表。
Non-serial/concurrent schedule
非連續/并發時間表
A schedule is said to be non-serial schedule if we start executing other transactions before computing the first one. A schedule in which sequence of instructions of transactions appear in the same order as they appear in individual transactions but the instructions may be interleaved with the instructions of different transactions i.e. concurrent execution of transaction takes place.
如果我們在計算第一個事務之前開始執行其他事務,則該調度被稱為非串行調度。 一種時間表,在該時間表中,交易的指令序列以與在單個交易中出現的順序相同的順序出現,但是指令可以與不同交易的指令交錯,即發生交易的同時執行。
翻譯自: https://www.includehelp.com/dbms/concurrency-and-problem-due-to-concurrency.aspx
oracle中dbms