TW201828117A - Database operation method and apparatus improving the transaction execution efficiency and increasing the throughput - Google Patents
Database operation method and apparatus improving the transaction execution efficiency and increasing the throughput Download PDFInfo
- Publication number
- TW201828117A TW201828117A TW106102692A TW106102692A TW201828117A TW 201828117 A TW201828117 A TW 201828117A TW 106102692 A TW106102692 A TW 106102692A TW 106102692 A TW106102692 A TW 106102692A TW 201828117 A TW201828117 A TW 201828117A
- Authority
- TW
- Taiwan
- Prior art keywords
- database
- operation instruction
- instruction
- execution
- database operation
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims abstract description 89
- 230000008569 process Effects 0.000 claims abstract description 46
- 238000002955 isolation Methods 0.000 claims description 39
- 230000004048 modification Effects 0.000 claims description 8
- 238000012986 modification Methods 0.000 claims description 8
- 238000012545 processing Methods 0.000 description 26
- 238000012546 transfer Methods 0.000 description 14
- 230000009286 beneficial effect Effects 0.000 description 12
- 238000010586 diagram Methods 0.000 description 10
- 238000004088 simulation Methods 0.000 description 9
- 230000008859 change Effects 0.000 description 6
- 238000004891 communication Methods 0.000 description 4
- 230000009467 reduction Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 230000008878 coupling Effects 0.000 description 3
- 238000010168 coupling process Methods 0.000 description 3
- 238000005859 coupling reaction Methods 0.000 description 3
- 230000003993 interaction Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 230000007812 deficiency Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Landscapes
- Vehicle Body Suspensions (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本發明涉及資料庫技術領域,尤其涉及一種資料庫操作方法及裝置。 The present invention relates to the field of database technology, and in particular, to a database operation method and apparatus.
資料庫事務(Database Transaction),是指作為單個邏輯工作單元執行的一系列操作,要麼完全地執行,要麼完全地不執行。一個事務由一系列資料庫操作指令構成,例如語句。 Database Transaction refers to a series of operations performed as a single logical unit of work, either completely or completely. A transaction consists of a series of database manipulation instructions, such as statements.
在資料庫操作中,為了保證併發讀取資料的正確性,提出了事務隔離級別的概念。在標準結構化查詢語言(Structured Query Language,SQL)規範中,定義了4個事務隔離級別,其中,讀已提交(Read Committed)是多數應用程式優選考慮的隔離級別,它可以避免髒讀取,而且具有較好的併發性能,但仍會遇到不可重複讀的問題。 In the database operation, in order to ensure the correctness of concurrent reading of data, the concept of transaction isolation level is proposed. In the Standard Structured Query Language (SQL) specification, four transaction isolation levels are defined. Among them, Read Committed is the isolation level that most applications prefer to avoid dirty reads. And it has better concurrency performance, but still encounters the problem of non-repeatable reading.
對於讀已提交隔離級別事務面臨的不可重複讀問題,可以透過for update語句臨時性的提升讀已提交隔離級別事務中某個資料的隔離級別,以保證該資料可重複讀取, 但這會嚴重降低系統的併發性能,導致執行效率較低,事務吞吐量較低。 For the non-repeatable read problem faced by reading the committed isolation level transaction, you can temporarily read the isolation level of a certain data in the submitted isolation level transaction through the for update statement to ensure that the data can be read repeatedly, but this will be seriously reduced. The concurrency of the system results in lower execution efficiency and lower transaction throughput.
本發明的多個方面提供一種資料庫操作方法及裝置,用以保證資料庫系統的併發性能,提高事務執行效率並增大事務吞吐量。 Aspects of the present invention provide a database operation method and apparatus for ensuring concurrent performance of a database system, improving transaction execution efficiency, and increasing transaction throughput.
本發明的一方面,提供一種資料庫操作方法,包括:在應用程式伺服器執行目標事務的過程中,依次獲取所述應用程式伺服器執行到的所述目標事務中的資料庫操作指令;對所述資料庫操作指令進行預測執行,將預測執行結果返回給所述應用程式伺服器以供所述應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄所述資料庫操作指令以及在所述資料庫操作指令屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一時記錄所述預測執行產生的預測執行資料;當獲取到所述目標事務中的事務提交指令時,根據本地記錄的所述資料庫操作指令以及所述預測執行資料,控制所述應用程式伺服器對應的資料庫實際執行所述目標事務。 An aspect of the present invention provides a database operation method, including: sequentially acquiring, in an execution process of an application server, a database operation instruction in the target transaction executed by the application server; The database operation instruction performs predictive execution, and returns a predicted execution result to the application server for the application server to determine a next database operation instruction to be executed, and locally records the database operation And predicting, when the database operation instruction belongs to one of a modified database class instruction and a locked non-modified database class instruction, predicting execution data generated by the prediction execution; when acquiring the transaction in the target transaction When the instruction is submitted, the database corresponding to the application server is controlled to actually execute the target transaction according to the database operation instruction and the predicted execution data recorded locally.
本發明的另一方面,提供一種資料庫操作方法,包括:在應用程式伺服器執行目標事務的過程中,依次獲取 所述應用程式伺服器執行到的所述目標事務中的資料庫操作指令;對所述資料庫操作指令進行預測執行,將預測執行結果返回給所述應用程式伺服器以供所述應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄所述資料庫操作指令以及在所述資料庫操作指令屬於被加鎖的非修改資料庫類指令時記錄所述預測執行產生的預測執行資料;當獲取到所述目標事務中的事務提交指令時,根據本地記錄的所述資料庫操作指令以及所述預測執行資料,控制所述應用程式伺服器對應的資料庫實際執行所述目標事務。 In another aspect of the present invention, a method for operating a database is provided, comprising: sequentially acquiring a database operation instruction in the target transaction executed by the application server during a process of executing a target transaction by an application server; Performing predictive execution on the database operation instruction, returning the predicted execution result to the application server for the application server to determine the next database operation instruction to be executed, and locally recording the database The operation instruction and the predicted execution data generated by the prediction execution when the database operation instruction belongs to the locked non-modified database class instruction; when the transaction commit instruction in the target transaction is obtained, according to the local record The database operation instruction and the predicted execution data, and the database corresponding to the application server is controlled to actually execute the target transaction.
本發明的又一方面,提供一種資料庫操作裝置,包括:獲取模組,用於在應用程式伺服器執行目標事務的過程中,依次獲取所述應用程式伺服器執行到的所述目標事務中的資料庫操作指令;預測執行模組,用於對所述資料庫操作指令進行預測執行,將預測執行結果返回給所述應用程式伺服器以供所述應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄所述資料庫操作指令以及在所述資料庫操作指令屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一時記錄所述預測執行產生的預測執行資料; 控制執行模組,用於當獲取到所述目標事務中的事務提交指令時,根據本地記錄的所述資料庫操作指令以及所述預測執行資料,控制所述應用程式伺服器對應的資料庫實際執行所述目標事務。 According to still another aspect of the present invention, a database operating device is provided, including: an obtaining module, configured to sequentially acquire the target transaction executed by the application server during a process of executing a target transaction by an application server a database operation instruction; a prediction execution module, configured to perform prediction execution on the database operation instruction, and return the prediction execution result to the application server for the application server to determine the next execution required a database operation instruction, and locally recording the database operation instruction and recording the prediction execution when the database operation instruction belongs to one of a modified database class instruction and a locked non-modified database class instruction And a control execution module, configured to: when the transaction commit instruction in the target transaction is obtained, control the application server according to the database operation instruction and the predicted execution data recorded locally The database actually executes the target transaction.
本發明的又一方面,提供一種資料庫操作裝置,包括:獲取模組,用於在應用程式伺服器執行目標事務的過程中,依次獲取所述應用程式伺服器執行到的所述目標事務中的資料庫操作指令;預測執行模組,用於對所述資料庫操作指令進行預測執行,將預測執行結果返回給所述應用程式伺服器以供所述應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄所述資料庫操作指令以及在所述資料庫操作指令屬於被加鎖的非修改資料庫類指令時記錄所述預測執行產生的預測執行資料;控制執行模組,用於當獲取到所述目標事務中的事務提交指令時,根據本地記錄的所述資料庫操作指令以及所述預測執行資料,控制所述應用程式伺服器對應的資料庫實際執行所述目標事務。 According to still another aspect of the present invention, a database operating device is provided, including: an obtaining module, configured to sequentially acquire the target transaction executed by the application server during a process of executing a target transaction by an application server a database operation instruction; a prediction execution module, configured to perform prediction execution on the database operation instruction, and return the prediction execution result to the application server for the application server to determine the next execution required a database operation instruction, and locally recording the database operation instruction and recording the predicted execution data generated by the prediction execution when the database operation instruction belongs to the locked non-modified database type instruction; controlling the execution module Controlling, when the transaction commit instruction in the target transaction is obtained, controlling the database corresponding to the application server to actually execute the target according to the database operation instruction recorded locally and the predicted execution data. Transaction.
在本發明中,資料庫操作裝置與應用程式伺服器相互配合,在應用程式伺服器執行目標事務的過程加入預測執行過程,預先獲得並記錄目標事務需要執行的全部資料庫操作指令,並僅針對屬於修改資料庫類指令和被加鎖的非修改資料庫類指令的資料庫操作指令,或者僅針對屬於被 加鎖的非修改資料庫類指令的資料庫操作指令記錄預測執行產生的預測執行資料,以適應於讀已提交隔離級別下的加鎖方案,為真實執行事務提供了條件,之後根據記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行該目標事務,有利於提高執行效率,進而增大事務吞吐量。 In the present invention, the database operating device cooperates with the application server to join the predictive execution process in the process of executing the target transaction by the application server, and obtains and records all the database operation instructions that need to be executed in the target transaction in advance, and only targets A database operation instruction that is a modified database class instruction and a locked non-modified database class instruction, or a prediction execution data generated only for a database operation instruction record belonging to a locked non-modified database class instruction record In order to adapt to the locking scheme under the submitted isolation level, provide conditions for the real execution of the transaction, and then control the database corresponding to the application server to actually execute the target transaction according to the recorded database operation instruction and the predicted execution data. It is beneficial to improve execution efficiency and thus increase transaction throughput.
10‧‧‧應用程式伺服器 10‧‧‧Application Server
20‧‧‧資料庫 20‧‧‧Database
30‧‧‧資料庫操作裝置 30‧‧‧Database operating device
51‧‧‧獲取模組 51‧‧‧Getting module
52‧‧‧預測執行模組 52‧‧‧Predictive Execution Module
53‧‧‧控制執行模組 53‧‧‧Control Execution Module
61‧‧‧獲取模組 61‧‧‧Get the module
62‧‧‧預測執行模組 62‧‧‧Predictive execution module
63‧‧‧控制執行模組 63‧‧‧Control Execution Module
為了更清楚地說明本發明實施例中的技術方案,下面將對實施例或現有技術描述中所需要使用的圖式作一簡單地介紹,顯而易見地,下面描述中的圖式是本發明的一些實施例,對於本領域普通技術人員來講,在不付出創造性勞動性的前提下,還可以根據這些圖式獲得其他的圖式。 In order to more clearly illustrate the technical solutions in the embodiments of the present invention, a brief description of the drawings used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are some of the present invention. For the embodiments, other drawings may be obtained according to these drawings without any creative labor.
圖1為現有技術中資料庫應用系統的部署圖;圖2為本發明一實施例提供的資料庫應用系統的部署圖;圖3為本發明另一實施例提供的資料庫操作方法的流程示意圖;圖4為本發明又一實施例提供的資料庫操作方法的流程示意圖;圖5為本發明又一實施例提供的資料庫操作裝置的結構示意圖;圖6為本發明又一實施例提供的資料庫操作裝置的結構示意圖。 1 is a deployment diagram of a database application system in the prior art; FIG. 2 is a deployment diagram of a database application system according to an embodiment of the present invention; FIG. 3 is a schematic flowchart of a database operation method according to another embodiment of the present invention; FIG. 4 is a schematic flowchart diagram of a database operation method according to another embodiment of the present invention; FIG. 5 is a schematic structural diagram of a database operation device according to another embodiment of the present invention; Schematic diagram of the structure of the database operating device.
為使本發明實施例的目的、技術方案和優點更加清楚,下面將結合本發明實施例中的圖式,對本發明實施例中的技術方案進行清楚、完整地描述,顯然,所描述的實施例是本發明一部分實施例,而不是全部的實施例。基於本發明中的實施例,本領域普通技術人員在沒有作出創造性勞動前提下所獲得的所有其他實施例,都屬於本發明保護的範圍。 The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
圖1為現有技術中資料庫應用系統的部署圖。如圖1所示,該系統包括:應用程式伺服器10和資料庫20。其中,應用程式伺服器10可以為一個,也可以為多個。資料庫20可以為一個,也可以為多個。圖1中僅示例性的示出一個應用程式伺服器10和一個資料庫20。當需要以事務方式對資料庫20進行存取時,應用程式伺服器10執行事務邏輯,依次將事務中的資料庫操作指令作用於資料庫20上。由於無法預先獲知事務中需要執行的資料庫操作指令,導致事務執行效率較低,尤其是在配置讀已提交隔離級別下透過for update語句對資料進行加鎖的方案中,其執行效率會更低,事務吞吐量較低。 FIG. 1 is a deployment diagram of a database application system in the prior art. As shown in FIG. 1, the system includes an application server 10 and a database 20. The application server 10 may be one or multiple. The database 20 may be one or plural. Only one application server 10 and one database 20 are shown by way of example in FIG. When the database 20 needs to be accessed in a transactional manner, the application server 10 executes the transaction logic to sequentially apply the database operation instructions in the transaction to the database 20. Because the database operation instructions that need to be executed in the transaction cannot be known in advance, the transaction execution efficiency is low, especially in the scheme of locking the data through the for update statement under the configuration read commit isolation level, the execution efficiency is lower. , transaction throughput is low.
針對現有技術存在的缺陷,本發明提供一種新的資料庫應用系統,如圖2所示。該系統在應用程式伺服器10和資料庫20之間增加資料庫操作裝置30。資料庫操作裝置30用以執行本發明提供的資料庫操作方法,在讀已提 交這一隔離級別下的加鎖方案中實現一種新的事務執行邏輯,即先對事務進行預測執行,提前獲得該事務中需要執行的資料庫操作指令,實現執行路徑的預測,並且結合讀已提交這一隔離級別且加鎖的情況,僅僅針對屬於修改資料庫類指令和被加鎖的非修改資料庫類指令的資料庫操作指令,或者僅僅針對屬於被加鎖的非修改資料庫類指令的資料庫操作指令記錄對其進行預測執行所產生的預測執行資料,進而基於預測執行得到的資料庫操作指令以及預測執行資料在資料庫20上實際執行事務,有利於提高事務執行效率,增大事務吞吐量。事務吞吐量是指單位時間內處理事務的數量。 In view of the deficiencies of the prior art, the present invention provides a new database application system, as shown in FIG. The system adds a database operating device 30 between the application server 10 and the database 20. The database operation device 30 is configured to execute the database operation method provided by the present invention, and implement a new transaction execution logic in the locking scheme under the read isolation level, that is, the prediction execution is performed on the transaction, and the transaction is obtained in advance. The database operation instruction that needs to be executed, realizes the prediction of the execution path, and combines the read and commit this isolation level and locks, only for the non-modified database class instruction belonging to the modified database class instruction and the locked database class instruction. The database operation instruction, or only the database execution instruction record belonging to the locked non-modified database class instruction record, the prediction execution data generated by the prediction execution, and the database operation instruction and the prediction execution based on the prediction execution The actual execution of the transaction on the database 20 is beneficial to improve transaction execution efficiency and increase transaction throughput. Transaction throughput is the number of transactions processed per unit of time.
值得說明的是,資料庫操作裝置30實際上是一種邏輯處理裝置,其可以單獨部署,位於應用程式伺服器10和資料庫20之間,也可以部署于應用程式伺服器10一端實現,或者也可以部署於資料庫20一端實現。 It should be noted that the database operating device 30 is actually a logical processing device, which can be deployed separately, between the application server 10 and the database 20, or can be deployed on one end of the application server 10, or Can be deployed on the end of the database 20 to achieve.
下面實施例將具體說明本發明技術方案的方法流程。 The following embodiment will specifically describe the method flow of the technical solution of the present invention.
圖3為本發明另一實施例提供的資料庫操作方法的流程示意圖。如圖3所示,該方法包括: FIG. 3 is a schematic flowchart diagram of a method for operating a database according to another embodiment of the present invention. As shown in FIG. 3, the method includes:
301、在應用程式伺服器執行目標事務的過程中,依次獲取應用程式伺服器執行到的目標事務中的資料庫操作指令。 301. In the process of executing the target transaction by the application server, sequentially acquiring the database operation instruction in the target transaction executed by the application server.
302、對資料庫操作指令進行預測執行,將預測執行結果返回給應用程式伺服器以供應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄資料庫操作 指令以及在資料庫操作指令屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一時記錄預測執行產生的預測執行資料。 302. Perform predictive execution on the database operation instruction, return the predicted execution result to the application server to supply the application server to determine the next database operation instruction to be executed, and record the database operation instruction locally and in the database. The operation instruction is a prediction execution data generated by the prediction execution when the operation instruction belongs to one of the modification database class instruction and the locked non-modified database class instruction.
303、當獲取到目標事務中的事務提交指令時,根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務。 303. When the transaction commit instruction in the target transaction is obtained, according to the locally recorded database operation instruction and the predicted execution data, the database corresponding to the application server is controlled to actually execute the target transaction.
首先說明,為便於描述,本實施例將應用程式伺服器需要執行的事務稱為目標事務。目標事務主要包括用於對資料庫進行操作的操作指令,除資料庫操作指令之外還包括一些用於控制目標事務執行狀態的控制指令,例如事務開始指令、事務提交指令、事務轉返(rollback)指令等。這些指令實際上是由資料庫語言編寫的語句。根據資料庫語言的不同,這些指令可以是不同語言編寫的語句。舉例說明,若採用SQL,則上述資料庫操作指令和控制指令實際上是一系列的SQL語句。 First, for convenience of description, the present embodiment refers to a transaction that the application server needs to execute as a target transaction. The target transaction mainly includes operation instructions for operating the database, and in addition to the database operation instruction, some control instructions for controlling the execution state of the target transaction, such as a transaction start instruction, a transaction commit instruction, and a transaction return (rollback) ) instructions, etc. These instructions are actually statements written in the database language. Depending on the language of the database, these instructions can be statements written in different languages. For example, if SQL is used, the above database operation instructions and control instructions are actually a series of SQL statements.
另外,在一些應用場景中,事務的處理需要先選中一些記錄,再對這些記錄進行處理,因此需要對選擇的記錄加排他鎖。這意味著,本實施例中的資料庫操作指令可能是加鎖的資料庫操作指令。例如,假設從Bob的帳戶裡轉出100元,這個操作由三步完成,查詢Bob的帳戶,判斷該帳戶是否夠100元,將Bob的帳戶裡的錢減少100塊。如果有兩個轉帳操作並行進行,當第一個轉帳操作查出Bob的帳戶的餘額,發現有100塊,如果這時候有另外一個轉帳操作也去查了Bob的帳戶,也發現Bob的帳戶裡 有100塊,於是這兩個轉帳操作都會進行轉帳,於是,第一個操作從Bob的帳戶減去100塊錢,另一個操作也從Bob的帳戶減去100塊錢,這時候,Bob的帳戶餘額就可能是負數。為了避免這種情況,需要使用for update來對Bob的帳戶加鎖,保證在第一個轉帳操作進行過程中,第二個轉帳操作無法獲得這個鎖,也就無法進行查詢。 In addition, in some application scenarios, the transaction processing needs to select some records first, and then process the records, so it is necessary to add an exclusive lock to the selected records. This means that the database operation instruction in this embodiment may be a locked database operation instruction. For example, suppose you transfer 100 yuan from Bob's account. This operation is completed in three steps. Query Bob's account, determine if the account is 100 yuan, and reduce the amount of money in Bob's account by 100. If there are two transfer operations in parallel, when the first transfer operation finds the balance of Bob's account, it finds that there are 100 pieces. If there is another transfer operation at this time, Bob's account is also checked, and Bob's account is also found. There are 100, so the two transfer operations will be transferred, so the first operation subtracts 100 bucks from Bob's account, and the other operation also subtracts 100 bucks from Bob's account. At this time, Bob's account The balance may be negative. In order to avoid this situation, you need to use for update to lock Bob's account, to ensure that during the first transfer operation, the second transfer operation can not obtain the lock, and therefore can not be queried.
本實施例提供的方法適用於對隔離級別為讀已提交的資料庫進行操作。其中,有些資料庫內定是讀已提交這一隔離級別,例如,Oracle資料庫內定是讀已提交這一隔離級別的,有些資料庫內定不是讀已提交這一隔離級別,例如MySQL資料庫內定是可重複讀這一隔離級別。基於此,在執行本實施例提供的方法之前,可以確定資料庫的隔離級別是否是讀已提交,若不是,則需要預先配置資料庫為讀已提交這一隔離級別。例如,可以在應用程式伺服器執行目標事務之前,配置資料庫為讀已提交這一隔離級別。 The method provided in this embodiment is applicable to operating a database whose isolation level is read and submitted. Among them, some databases are determined to read this isolation level. For example, the Oracle database defaults to read the isolation level that has been submitted. Some databases do not specify the isolation level that has been submitted. For example, the MySQL database defaults to This isolation level can be read repeatedly. Based on this, before performing the method provided in this embodiment, it can be determined whether the isolation level of the database is a read commit, and if not, the database needs to be pre-configured to read the isolation level. For example, you can configure the repository to read this isolation level before the application server executes the target transaction.
在資料庫的隔離級別為讀已提交的前提下,可以執行本實施例提供的方法以在資料庫中執行目標事務。具體流程如下:應用程式伺服器控制整個目標事務的執行邏輯,可以按照現有方式執行目標事務。資料庫操作裝置在應用程式伺服器執行目標事務的過程中,依次獲取應用程式伺服器執行到的目標事務中的資料庫操作指令。 Under the premise that the isolation level of the database is read, the method provided in this embodiment may be executed to execute the target transaction in the database. The specific process is as follows: The application server controls the execution logic of the entire target transaction, and the target transaction can be executed in the existing manner. The database operating device sequentially acquires the database operation instruction in the target transaction executed by the application server during the execution of the target transaction by the application server.
在一可選實施方式中,應用程式伺服器按照現有方式 向資料庫發送資料庫操作指令,以實現對資料庫的存取。資料庫操作裝置可以對應用程式伺服器與資料庫之間的通信進行監控,以攔截應用程式伺服器發往資料庫的資料庫操作指令。 In an alternative embodiment, the application server sends a database operation instruction to the database in an existing manner to enable access to the database. The database operating device can monitor the communication between the application server and the database to intercept the database operation instructions sent by the application server to the database.
在另一可選實施方式中,對應用程式伺服器的處理邏輯進行稍微修改,將原來向資料庫發送資料庫操作指令的處理邏輯改為向資料庫操作裝置發送。基於此,資料庫操作裝置可以接收應用程式伺服器主動下發的資料庫操作指令。 In another alternative embodiment, the processing logic of the application server is slightly modified, and the processing logic that originally sent the database operation instruction to the database is changed to be sent to the database operating device. Based on this, the database operating device can receive the database operation instruction actively issued by the application server.
在此說明,若目標事務是顯式事務,則目標事務中的首個指令是事務開始指令,如開始事務(begin transaction),基於此,資料庫操作裝置在獲取應用程式伺服器執行到的資料庫操作指令之前,可以攔截應用程式伺服器發往資料庫的目標事務中的事務開始指令,根據該事務開始指令,獲知需要執行目標事務。或者,資料庫操作裝置在獲取應用程式伺服器執行到的資料庫操作指令之前,可以接收應用程式伺服器主動下發的目標事務中的事務開始指令,根據該事務開始指令,獲知需要執行目標事務。若目標事務是隱式事務,則目標事務的首個指令就是資料庫操作指令,不包括獲取事務開始指令的步驟。 Here, if the target transaction is an explicit transaction, the first instruction in the target transaction is a transaction start instruction, such as a begin transaction, based on which the database operation device acquires the data executed by the application server. Before the library operation instruction, the transaction start instruction in the target transaction sent by the application server to the database can be intercepted, and according to the transaction start instruction, the target transaction needs to be executed. Alternatively, the database operating device may receive a transaction start instruction in the target transaction actively issued by the application server before acquiring the database operation instruction executed by the application server, and according to the transaction start instruction, learn that the target transaction needs to be executed. . If the target transaction is an implicit transaction, the first instruction of the target transaction is the database operation instruction, and does not include the step of obtaining the transaction start instruction.
資料庫操作裝置在獲取應用程式伺服器執行到的資料庫操作指令後,對獲取到的資料庫操作指令進行預測執行,將預測執行結果返回給應用程式伺服器,以供應用程式伺服器確定下一個需要執行的資料庫操作指令。其中, 預測執行結果決定著目標事務的執行路徑,這裡的執行路徑是指資料庫操作指令之間的跳轉邏輯。透過將預測執行結果返回給應用程式伺服器,從而達到由應用程式伺服器控制整個目標事務的執行邏輯的目的。 After obtaining the database operation instruction executed by the application server, the database operation device performs predictive execution on the acquired database operation instruction, returns the predicted execution result to the application server, and determines the supply server program. A database operation instruction that needs to be executed. The predicted execution result determines the execution path of the target transaction, where the execution path refers to the jump logic between the database operation instructions. By returning the predicted execution result to the application server, the purpose of controlling the execution logic of the entire target transaction by the application server is achieved.
另外,資料庫操作裝置還需要在本地記錄所獲取到的資料庫操作指令,以及在該資料庫操作指令屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一時,記錄對該資料庫操作指令進行預測執行產生的預測執行資料。所述修改資料庫類指令是指對資料庫有修改的資料庫操作指令,例如以update、insert等開頭的指令;一般以select開頭的指令不屬於修改資料庫類指令(稱為非修改資料庫類指令)。雖然從本質而言,讀已提交隔離級別只保證寫入多個資料是原子的,不在讀取的時候加鎖,但為了保證事務的一致性,降低轉返概率,有些非修改資料庫類指令可能需要透過for update語句進行加鎖,例如在上面轉帳舉例中,select指令需要加鎖,形成select......forupdate形式的資料庫操作指令,這種指令可稱為被加鎖的非修改資料庫類指令。所述預測執行資料主要是指對資料庫操作指令進行預測執行過程中的一些資料,例如資料庫操作指令所操作的資料以及資料的主鍵ID和主鍵ID對應的版本號資訊(version)等。 In addition, the database operating device also needs to locally record the acquired database operation instruction, and when the database operation instruction belongs to one of the modified database class instruction and the locked non-modified database class instruction, the record pair The database operation instruction performs prediction execution data generated by the prediction execution. The modified database class instruction refers to a database operation instruction that has a modified database, for example, an instruction that starts with update, insert, etc.; generally, an instruction that starts with a select does not belong to a modified database class instruction (referred to as a non-modified database). Class instruction). Although in essence, reading the submitted isolation level only guarantees that writing multiple data is atomic, and does not lock when reading, but in order to ensure transaction consistency, reduce the probability of return, some non-modified database class instructions It may need to be locked by the for update statement. For example, in the above transfer example, the select instruction needs to be locked to form a database operation instruction in the form of select...forupdate, which can be called a locked non- Modify the database class directive. The predicted execution data mainly refers to some data in the process of predictive execution of the database operation instruction, such as the data operated by the database operation instruction, the primary key ID of the data, and the version number information corresponding to the primary key ID.
值得說明的是,對於同一資料庫操作指令來說,要麼屬於修改資料庫類指令,要麼屬於被加鎖的非修改資料庫類指令,要麼屬於未加鎖的非修改資料庫類指令。但是, 從整個目標事務來看,對於該目標事務中所有修改資料庫類指令以及所有被加鎖的非修改資料庫類指令預測執行產生的預測執行資料都會被記錄在本地。 It is worth noting that for the same database operation instruction, it is either a modified database class instruction, a locked non-modified database class instruction, or an unlocked non-modified database class instruction. However, from the perspective of the entire target transaction, the predicted execution data generated by all the modified database class instructions and all the locked non-modified database class instructions in the target transaction will be recorded locally.
例如,資料庫操作裝置可以在本地創建記憶體庫,將所獲取到的資料庫操作指令以及預測執行資料存入記憶體庫中。進一步,若預測執行資料不包括預測執行結果,則也可以將預測執行結果存入記憶體庫中。 For example, the database operating device may locally create a memory library, and store the acquired database operation instructions and predicted execution data in a memory library. Further, if the predicted execution data does not include the predicted execution result, the predicted execution result may also be stored in the memory bank.
為了在預測執行這一核心思想的基礎上實現對讀已提交這一隔離級別下的加鎖方案的模擬,本實施例針對屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一的資料庫操作指令,記錄其預測執行產生的預測執行資料,卻不記錄屬於未被加鎖的非修改資料庫類指令的資料庫操作指令對應的預測執行資料。由此可見,在實現讀已提交這一隔離級別下的加鎖方案的情況下,所記錄的資料量相對較少,這樣在後續基於本地記錄的資料庫操作指令和預測執行資料在資料庫中真實執行目標事務的過程中,所需處理的資料量相對較少,有利於進一步提高執行效率和性能,增大事務吞吐量。 In order to implement the simulation of the locking scheme under the isolation level that has been submitted for reading on the basis of the core idea of predictive execution, this embodiment is directed to the instruction of the modified database class and the locked non-modified database class instruction. One of the database operation instructions records the predicted execution data generated by the prediction execution, but does not record the predicted execution data corresponding to the database operation instruction of the unmodified non-modified database type instruction. It can be seen that in the case of realizing that the lock scheme under the isolation level has been submitted, the amount of recorded data is relatively small, so that the subsequent database-based operation instructions and prediction execution data based on the local record are in the database. In the process of real execution of the target transaction, the amount of data to be processed is relatively small, which is beneficial to further improve execution efficiency and performance, and increase transaction throughput.
其中,資料庫操作指令對資料庫的操作主要是存取資料庫中的資料,則可以模擬資料庫操作指令的資料環境,基於所模擬的資料環境對資料庫操作指令進行預測執行。進一步,考慮到屬於非修改資料庫類指令的資料庫操作指令不會引起資料庫的變化,因此可以直接在資料庫中對該資料庫操作指令進行預測執行,這樣可以節約模擬資料環 境的操作,實現相對簡單,有利於節約資源,提高執行效率。但是,對於屬於修改資料庫類指令的資料庫操作指令,由於其會引起資料庫的變化(主要是指資料庫中的資料被改變),因此需要模擬資料環境,在所模擬的資料環境中進行預測執行。 The operation of the database operation instruction on the database mainly refers to accessing the data in the database, and the data environment of the database operation instruction can be simulated, and the database operation instruction is predicted and executed based on the simulated data environment. Further, considering that the database operation instruction belonging to the non-modified database class instruction does not cause the change of the database, the database operation instruction can be directly predicted and executed in the database, thereby saving the operation of the simulation data environment. The implementation is relatively simple, which is conducive to saving resources and improving execution efficiency. However, for the database operation instruction belonging to the modified database class instruction, since it will cause the database to change (mainly the data in the database is changed), the simulation data environment is required to be performed in the simulated data environment. Forecast execution.
基於上述分析,一種對資料庫操作指令進行預測執行的方式可以是:對獲取到的資料庫操作指令的類別進行識別;若資料庫操作指令屬於修改資料庫類指令,則在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於所模擬的資料環境對資料庫操作指令進行預測執行;若資料庫操作指令屬於非修改資料庫類指令,在資料庫中執行該資料庫操作指令,以對該資料庫操作指令進行預測執行。 Based on the above analysis, a method for predictive execution of the database operation instruction may be: identifying the category of the obtained database operation instruction; if the database operation instruction belongs to the modification database type instruction, the locally created memory The data environment of the simulation database operation instruction in the library performs prediction execution on the database operation instruction based on the simulated data environment; if the database operation instruction belongs to the non-modified database type instruction, the database operation instruction is executed in the database, Predictive execution of the database operation instructions.
進一步,一種在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於所模擬的資料環境對資料庫操作指令進行預測執行的實施方式包括:將獲取到的資料庫操作指令拆分為一個讀指令和一個寫指令,將讀指令運行於真正的資料庫上,即在資料庫中執行該讀指令以獲取讀資料集(ReadSet),將讀資料集存入本地記憶體庫中,以模擬資料庫操作指令所需的資料環境。然後,將寫指令作用於記憶體庫上,以實現對資料庫操作指令的預測執行,即在記憶體庫中執行寫指令以修改讀資料集,例如對讀資料集中的有關資料進行更新或查 詢處理等。其中,執行寫指令以修改讀資料集可以產生結果資料集(affectRowInMemdb),該結果資料集包括預測執行結果。 Further, a data environment for simulating a database operation instruction in a locally created memory library, and an implementation manner of predicting execution of the database operation instruction based on the simulated data environment includes: splitting the obtained database operation instruction into A read instruction and a write instruction, the read instruction is run on a real database, that is, the read instruction is executed in the database to obtain a read data set (ReadSet), and the read data set is stored in the local memory library, The data environment required to simulate database operations instructions. Then, the write command is applied to the memory bank to implement predictive execution of the database operation instruction, that is, executing a write instruction in the memory bank to modify the read data set, for example, updating or querying related data in the read data set. Processing and so on. Wherein, executing a write command to modify the read data set may generate a result data set (affectRowInMemdb), the result data set including the predicted execution result.
在上述預測執行過程中,若資料庫操作指令屬於修改資料庫類指令,則資料庫操作裝置可以在本地記錄讀指令所讀取的讀資料集以及執行寫指令產生的結果資料集。由此可見,所述預測執行資料可以包括讀資料集和結果資料集,或者也可以包括讀資料集和結果資料集中的部分資料,例如能夠對在資料庫中實際執行目標事務產生有益效果的一些資料,例如一些數值的各種索引,例如一級索引、二級索引、主鍵ID、版本號等。 In the above prediction execution process, if the database operation instruction belongs to the modification database class instruction, the database operation device can locally record the read data set read by the read instruction and the result data set generated by executing the write instruction. It can be seen that the predicted execution data may include a read data set and a result data set, or may also include some data in the read data set and the result data set, for example, some of the beneficial effects on the actual execution of the target transaction in the database. Data, such as various indexes of some values, such as primary index, secondary index, primary key ID, version number, and so on.
較優的,為了進一步減少記錄的資料量,在資料庫操作指令屬於被加鎖的非修改資料庫類指令時,可以僅記錄該資料庫操作指令所操作的資料的主鍵ID和版本號作為預測執行資料。這樣在後續基於本地記錄的資料庫操作指令和預測執行資料在資料庫中真實執行目標事務的過程中,所需處理的資料量會進一步較少,有利於進一步提高執行效率和性能,增大事務吞吐量。另外,有時資料在事務過程中可能會經過多次修改,但最終又回到初始值,但資料的主鍵ID和版本號不會發生變化。因此,若採用記錄資料本身的方式,在預測執行與真實執行進行比較時資料可能不一樣,就要發生轉返,而轉返的代價較大。但是,本實施例採用只記錄資料的主鍵ID和版本號的方式,在預測執行與真實執行進行比較時出現不一致的概率 較低,轉返概率較低。 Preferably, in order to further reduce the amount of recorded data, when the database operation instruction belongs to the locked non-modified database class instruction, only the primary key ID and version number of the data operated by the database operation instruction may be recorded as a prediction. Execution data. In this way, in the subsequent process of realizing the target transaction in the database based on the local record-based database operation instruction and the prediction execution data, the amount of data to be processed is further reduced, which is beneficial to further improve the execution efficiency and performance, and increase the transaction. Throughput. In addition, sometimes the data may be modified several times during the transaction, but eventually return to the initial value, but the primary key ID and version number of the data will not change. Therefore, if the method of recording the data itself is used, the data may be different when the forecast execution is compared with the real execution, and the return will occur, and the cost of the return is greater. However, in this embodiment, the method of recording only the primary key ID and the version number of the data is adopted, and the probability of occurrence of inconsistency when the prediction execution is compared with the actual execution is low, and the probability of the return is low.
當資料庫操作裝置獲取到目標事務中的事務提交指令(即應用程式伺服器執行到事務提交指令)時,則可以根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務。 When the database operation device acquires the transaction commit instruction in the target transaction (that is, the application server executes to the transaction commit instruction), it can control the corresponding application server according to the locally recorded database operation instruction and the predicted execution data. The database actually performs the target transaction.
上述根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務的一種可選實施方式包括:資料庫操作裝置向資料庫下發本地記錄的所述資料庫操作指令,以指示資料庫執行資料庫操作指令,並接收資料庫返回的資料庫操作指令的實際執行結果;然後,將資料庫操作指令的實際執行結果與預測執行結果進行比較,若實際執行結果與預測執行結果相同,向資料庫下發事務提交指令,以供資料庫提交該目標事務;若實際執行結果與預測執行結果不相同,向資料庫下發事務轉返指令,以供資料庫轉返該目標事務。 In the above, according to the locally recorded database operation instruction and the predicted execution data, an optional implementation manner of controlling the database corresponding to the application server to actually execute the target transaction includes: the database operation device delivering the locally recorded data to the database a library operation instruction to instruct the database to execute the database operation instruction, and receive the actual execution result of the database operation instruction returned by the database; and then compare the actual execution result of the database operation instruction with the predicted execution result, if the actual execution The result is the same as the predicted execution result, and the transaction commit instruction is sent to the database for the database to submit the target transaction; if the actual execution result is different from the predicted execution result, the transaction return instruction is sent to the database for the database. Transfer back to the target transaction.
在上述實施方式中,考慮到事務的原子性,透過將實際執行結果與預測執行結果進行比較,可以避免事務執行過程出錯,有利於提高事務執行的成功概率。 In the above embodiment, considering the atomicity of the transaction, by comparing the actual execution result with the predicted execution result, the transaction execution process error can be avoided, and the success probability of the transaction execution is improved.
進一步,在現有技術中,由於無法預先知道事務需要執行的全部資料庫操作指令,所以只能按照事務的執行邏輯依次執行資料庫操作指令,這會導致應用程式伺服器與資料庫之間的頻繁互動,這在遠程應用場景中將會消耗大量網路資源。但在本實施例中,透過預測執行過程已經預 先獲得目標事務需要執行的全部資料庫操作指令,即本地記錄的資料庫操作指令,因此在向資料庫下發本地記錄的資料庫操作指令,以指示資料庫執行資料庫操作指令的過程中,可以將本地記錄的資料庫操作指令同時(或者一併)下發到資料庫,有利於節約網路資源。另外,對於一些並行的資料庫操作指令,資料庫還可以並行操作,有利於進一步提高事務執行效率,增大事務吞吐量。 Further, in the prior art, since all the database operation instructions that the transaction needs to execute cannot be known in advance, the database operation instruction can be executed sequentially according to the execution logic of the transaction, which causes frequent interaction between the application server and the database. This will consume a lot of network resources in the remote application scenario. However, in this embodiment, all the database operation instructions that need to be executed by the target transaction, that is, the local record database operation instruction, have been obtained in advance through the prediction execution process, so that the local record database operation instruction is sent to the database to In the process of instructing the database to execute the database operation instruction, the local record database operation instruction can be simultaneously (or collectively) sent to the database, which is conducive to saving network resources. In addition, for some parallel database operation instructions, the database can also operate in parallel, which is beneficial to further improve transaction execution efficiency and increase transaction throughput.
進一步,還可以將本地記錄的所有資料庫操作指令連同本地記錄的預測執行資料一併下發給資料庫。 Further, all the database operation instructions recorded locally can be sent to the database together with the locally recorded predicted execution data.
進一步,在一種根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務的可選實施方式中,資料庫操作裝置可以根據本地記錄的資料庫操作指令,判斷目標事務是否為單機事務;若判斷結果為是,則根據本地記錄的資料庫操作指令以及預測執行資料,以單機事務處理邏輯控制資料庫實際執行目標事務;若判斷結果為否,則根據本地記錄的資料庫操作指令以及預測執行資料,以分布式事務處理邏輯控制資料庫實際執行目標事務。 Further, in an optional implementation manner of controlling a database corresponding to the actual execution of the target transaction according to the locally recorded database operation instruction and the predicted execution data, the database operation device may operate the instruction according to the locally recorded database. , determining whether the target transaction is a stand-alone transaction; if the determination result is yes, according to the locally recorded database operation instruction and the predicted execution data, the single-machine transaction processing logic controls the database to actually execute the target transaction; if the judgment result is no, then according to The locally recorded database operation instructions and the predicted execution data, and the distributed transaction logic control the database to actually execute the target transaction.
其中,基於預測執行過程中獲得的資料庫操作指令可以識別出目標事務是單機事務還是分布式事務。例如,可以判斷本地記錄的資料庫操作指令的操作對象是否作用於同一實體設備上,若判斷結果為是,則可以確定該目標事務為單機事務;若判斷結果為否,則可以確定該目標事務為分布式事務。 The database operation instruction obtained during the prediction execution process can identify whether the target transaction is a stand-alone transaction or a distributed transaction. For example, it may be determined whether the operation object of the locally recorded database operation instruction acts on the same entity device. If the determination result is yes, the target transaction may be determined to be a stand-alone transaction; if the determination result is negative, the target transaction may be determined. For distributed transactions.
由於分布式事務的處理邏輯和單機事務的處理邏輯有所不同,單機事務的處理邏輯相對簡單,例如不涉及讀寫加鎖等問題,所以所消耗的資源也相對較少。基於此,本實施例透過識別目標事務是否為單機事務,在識別為單機事務時採用單機事務的處理邏輯進行處理,而不是像現有技術那樣統一採用分布式事務處理邏輯進行處理,有利於提高處理效率,節約處理成本。 Because the processing logic of distributed transactions is different from the processing logic of stand-alone transactions, the processing logic of single-machine transactions is relatively simple, for example, it does not involve problems such as read-write and lock, so the resources consumed are relatively small. Based on this, the present embodiment uses the processing logic of the single-machine transaction to identify the target transaction as a single-machine transaction, instead of using the distributed transaction processing logic to process the same as the prior art, which is beneficial to improve processing. Efficiency, saving processing costs.
在一可選實施方式中,若資料庫操作裝置獲取到目標事務中的事務轉返指令(即應用程式伺服器執行到事務轉返指令)時,可以刪除本地記錄的資料庫操作指令以及預測執行資料,例如可以直接清空本地記憶體庫,實現轉返操作。在該情況下,由於目標事務並未在資料庫中真正執行,所以資料庫無需執行轉返操作,可見,在事務轉返這種情況下,採用本實施例方法也可以提高事務執行效率。 In an optional implementation manner, if the database operation device acquires a transaction return instruction in the target transaction (ie, the application server executes to the transaction return instruction), the local record database operation instruction and the prediction execution may be deleted. For example, the local memory bank can be directly emptied to implement the transfer operation. In this case, since the target transaction is not actually executed in the database, the database does not need to perform the transfer operation. It can be seen that in the case of the transaction return, the transaction efficiency can be improved by using the method of the embodiment.
由上述可見,在本實施例提供的方法中,資料庫操作裝置與應用程式伺服器相互配合,在應用程式伺服器執行目標事務的過程加入預測執行過程,在預測執行過程中,可以提前獲得目標事務的執行路徑,即真正需要執行的資料庫操作指令,並僅針對屬於修改資料庫類指令的資料庫操作指令,或者僅針對屬於被加鎖的非修改資料庫類指令的資料庫操作指令記錄預測執行產生的預測執行資料,以適應於讀已提交隔離級別下的加鎖方案,為真實執行事務提供了條件,之後在根據記錄的資料庫操作指令以及預測執行資料實際執行該目標事務時,例如基於預測執行資料 可以提前獲取有關資料資訊並且可以減少指令之間的跳轉等,因此可以提高執行效率,增大事務吞吐量。 It can be seen from the above that in the method provided by the embodiment, the database operation device cooperates with the application server to join the prediction execution process in the process of executing the target transaction by the application server, and the target can be obtained in advance during the prediction execution process. The execution path of the transaction, that is, the database operation instruction that really needs to be executed, and only for the database operation instruction belonging to the modified database class instruction, or only for the database operation instruction record belonging to the locked non-modified database class instruction. Predicting the execution data generated by the execution to adapt to the locking scheme under the submitted isolation level, providing conditions for the real execution of the transaction, and then actually executing the target transaction based on the recorded database operation instructions and the predicted execution data. For example, based on the predicted execution data, the related information information can be obtained in advance and the jump between instructions can be reduced, thereby improving execution efficiency and increasing transaction throughput.
下面以減庫存事務為例,詳細說明本發明技術方案的工作流程。其中,資料庫的隔離級別為讀已提交這一隔離級別。 In the following, taking the inventory reduction transaction as an example, the workflow of the technical solution of the present invention will be described in detail. The isolation level of the database is the isolation level that the read has been submitted.
減庫存事務的SQL代碼如下,括號內的文字為注釋:begin transaction(開始事務)select * from inventory where itemId=?for update(用商品id查看當前庫存,注意這裡用for update外部顯示加鎖)if(item.inventory>0)item.inventory--;update inventory set item.inventory=$item.inventory where itemId=?commit;else rollback;(如果當前庫存大於0,則減少、更新商品庫存並提交,否則轉返) The SQL code for the inventory reduction transaction is as follows, the text in parentheses is the comment: begin transaction (select transaction) select * from inventory where itemId=? For update (use commodity id to view current inventory, note that for update external display lock) if (item.inventory>0) item.inventory--;update inventory set item.inventory=$item.inventory where itemId=? Commit; else rollback; (if the current inventory is greater than 0, reduce, update the merchandise inventory and submit, otherwise return)
在實際執行過程中,應用程式伺服器負責該減庫存事務的整個邏輯,資料庫操作裝置(或者也可稱為執行伺服器)只會獲取應用程式伺服器執行到的開始事務,需要執行的SQL語句,以及提交/轉返指令。 In the actual execution process, the application server is responsible for the whole logic of the inventory reduction transaction. The database operation device (or also called the execution server) only gets the start transaction executed by the application server, and the SQL to be executed. Statements, as well as commit/return instructions.
首先,開始事務後,資料庫操作裝置在本地創建記憶體庫;當資料庫操作裝置獲取到select * from inventory where itemId=?for update這條SQL語句時,識別出這條SQL語句不會修改資料庫,因此將這條SQL語句直接作用在實際資料庫中,即在資料庫中執行該條SQL語句以獲得查詢結果,即讀資料集,將全部查詢結果返回給應用程式伺服器,以供應用程式伺服器確定下一個需要執行的SQL語句,並在本地記憶體庫中記錄這條SQL語句。雖然是讀已隔離級別,但由於該語句被加鎖,故需要記錄執行該條SQL語句有關的資料,優選的可以僅記錄該SQL語句所查詢的資料的主鍵ID和版本號(version)。 First, after starting the transaction, the database operating device creates a memory library locally; when the database operating device obtains select * from inventory where itemId=? For update this SQL statement, it is recognized that this SQL statement will not modify the database, so this SQL statement directly acts on the actual database, that is, execute the SQL statement in the database to obtain the query result, ie Read the data set, return all the query results to the application server, and supply the application server to determine the next SQL statement to be executed, and record the SQL statement in the local memory library. Although the read level has been read, since the statement is locked, it is necessary to record the data related to executing the SQL statement. Preferably, only the primary key ID and the version number of the data queried by the SQL statement can be recorded.
應用程式伺服器收到資料庫操作裝置返回的查詢結果後,判斷查詢結果中當前庫存量是否大於0,若判斷結果為是,則將當前庫存量減少,並執行更新語句,即update inventory set item.inventory=$item.inventory where itemId=?;若判斷結果為否,則執行rollback語句。 After receiving the query result returned by the database operation device, the application server determines whether the current inventory quantity in the query result is greater than 0. If the determination result is yes, the current inventory quantity is reduced, and the update statement is executed, that is, the update inventory set item .inventory=$item.inventory where itemId=? If the result of the judgment is no, the rollback statement is executed.
第一種情況,假設應用程式伺服器執行了rollback語句,則資料庫操作裝置會獲取到rollback語句。一旦資料庫儲存裝置獲取到rollback語句,則清空本地記憶體庫,主要是指清空之前記錄的select * from inventory where itemId=?for update這條SQL語句。在這種情況下,因為事務並沒有在資料庫中執行,所以無需資料庫執行轉返操作。 In the first case, if the application server executes the rollback statement, the database operating device will get the rollback statement. Once the database storage device obtains the rollback statement, the local memory library is emptied, mainly to clear the previously selected select * from inventory where itemId=? For update this SQL statement. In this case, because the transaction is not executed in the repository, there is no need for the repository to perform the rollback operation.
第二種情況,假設應用程式伺服器執行了update inventory set item.inventory=$item.inventory where itemId=?這條語句,則資料庫操作裝置會獲取到update inventory set item.inventory=$item.inventory where itemId=?這條語句。則資料庫操作裝置獲取到update inventory set item.inventory=?where itemId=?這條SQL語句時,識別出該SQL語句會修改資料庫,於是將這條SQL語句拆解為一個讀指令,即select * from inventory where itemId=?和一個寫指令,即update inventory set item.inventory=?where itemId=?;接著,將select * from inventory where itemId=?這個語句下發到資料庫中,獲得讀資料集,將讀資料集中的資料寫入本地記憶體庫中;其中,讀資料集中包括主鍵列表(itemId)和該主鍵對應的版本號(version)。然後,根據update inventory set item.inventory=?where itemId=?這個語句在本地記憶體庫中進行更新操作,以獲得結果資料集,並將結果資料集返回給應用程式伺服器。該結果資料集可以是類似修改了幾條記錄這樣的修改記錄資訊,例如,affectRow=1表示修改了一條記錄;或者,結果資料集也可以是記錄修改詳細資訊的修改詳情資訊。其中,結果資料集和讀資料集構成預測執行資料。 In the second case, assume that the application server has executed update inventory set item.inventory=$item.inventory where itemId=? In this statement, the database operating device will get update inventory set item.inventory=$item.inventory where itemId=? This statement. Then the database operating device obtains update inventory set item.inventory=? Where itemId=? This SQL statement recognizes that the SQL statement will modify the database, so the SQL statement is split into a read command, ie select * from inventory where itemId=? And a write command, ie update inventory set item.inventory=? Where itemId=? Then, select * from inventory where itemId=? The statement is sent to the database, and the read data set is obtained, and the data in the read data set is written into the local memory library; wherein the read data set includes a primary key list (itemId) and a version number corresponding to the primary key. Then, according to update inventory set item.inventory=? Where itemId=? This statement is updated in the local memory library to obtain the result data set and return the result data set to the application server. The result data set may be modified record information similar to the modification of several records. For example, affectRow=1 indicates that a record is modified; or the result data set may also be modified details of the record modification detailed information. Among them, the result data set and the read data set constitute prediction execution data.
應用程式伺服器此時執行commit指令。 The application server executes the commit command at this time.
當資料庫操作裝置獲取到commit指令後,基於本地記憶體庫中的SQL語句以及預測執行資料,在資料庫中執行該減庫存事務,這次事務執行過程是真實執行的。例如,本地記錄的SQL語句以及預測執行資料如下所示: {select * from inventory where itemId=?update inventory set item.inventory=?where itemId=?【readVersion:itemId=xxx and version=xxx /affectRow=1】commit()} After the database operation device obtains the commit command, the inventory reduction transaction is executed in the database based on the SQL statement in the local memory library and the predicted execution data, and the transaction execution process is actually performed. For example, the locally recorded SQL statement and the predicted execution data are as follows: {select * from inventory where itemId=? Update inventory set item.inventory=? Where itemId=? [readVersion:itemId=xxx and version=xxx /affectRow=1]commit()}
優選的,資料庫操作裝置可以一次性將本地記憶體庫中的SQL語句全部提交到資料庫中,資料庫基於此進行執行,有利於節約傳輸SQL語句所消耗的網路資源。 Preferably, the database operating device can submit all the SQL statements in the local memory library to the database at one time, and the database is executed based on the data, thereby saving the network resources consumed by the transmission of the SQL statement.
這次真實執行也會返回執行結果,可以將預測執行結果與實際執行結果進行比較,例如可以先比較兩個結果中的主鍵ID和版本號,然後再比較兩個結果中的affectRow;如果比較結果為相同,則可以在資料庫中提交這次事務,而如果比較結果為不相同,則認為提交是失敗的,由於在這種情況下,事務本身其實一直都沒有真正的在資料庫中執行提交,所以可以簡單地轉返整個請求,讓應用程式伺服器重新提交即可。 This real execution will also return the execution result. You can compare the predicted execution result with the actual execution result. For example, you can compare the primary key ID and version number of the two results, and then compare the affectRow of the two results; if the comparison result is The same, you can submit this transaction in the database, and if the comparison results are not the same, then the submission is considered to be a failure, because in this case, the transaction itself has not actually executed the submission in the database, so Simply return the entire request and let the application server resubmit.
其中,經過上述預測執行,已經獲得了所有的需要執行的SQL語句,以及相應的預測執行資料,例如全部切分條件,數值的索引、版本號等,而這些資料足以讓我們提前對事務是否是單機事務做出判斷。基於此,可以採用相應的事務處理邏輯進行處理,有利於節約資源。 Among them, after the above prediction execution, all the SQL statements that need to be executed, and the corresponding predicted execution data, such as all the segmentation conditions, the index of the value, the version number, etc., have been obtained, and the data is sufficient for us to advance whether the transaction is The single machine transaction makes a judgment. Based on this, the corresponding transaction logic can be used for processing, which is conducive to saving resources.
圖4為本發明又一實施例提供的資料庫操作方法的流程示意圖。如圖4所示,該方法包括: FIG. 4 is a schematic flowchart diagram of a method for operating a database according to another embodiment of the present invention. As shown in FIG. 4, the method includes:
401、在應用程式伺服器執行目標事務的過程中,依次獲取應用程式伺服器執行到的目標事務中的資料庫操作指令。 401. In the process of executing the target transaction by the application server, sequentially acquiring the database operation instruction in the target transaction executed by the application server.
402、對資料庫操作指令進行預測執行,將預測執行結果返回給應用程式伺服器以供應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄資料庫操作指令以及在資料庫操作指令屬於被加鎖的非修改資料庫類指令時記錄預測執行產生的預測執行資料。 402. Perform predictive execution on the database operation instruction, return the predicted execution result to the application server to supply the application server to determine the next database operation instruction to be executed, and record the database operation instruction locally and in the database. The operation execution instruction records the prediction execution data generated by the prediction execution when it belongs to the locked non-modified database class instruction.
403、當獲取到目標事務中的事務提交指令時,根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務。 403. When the transaction commit instruction in the target transaction is obtained, according to the locally recorded database operation instruction and the predicted execution data, the database corresponding to the application server is controlled to actually execute the target transaction.
本實施例與圖3所示實施例相類似,區別在於:僅記錄目標事務中被加鎖的非修改資料庫類指令的預測執行產生的預測執行資料,對於修改資料庫類指令的預測執行產生的預測執行資料以及未加鎖的非修改資料庫類指令的預測執行產生的預測執行資料不作記錄。另外,本實施例適用於目標事務包括被加鎖的非修改資料庫類指令的情況,所操作的資料庫不僅可以是隔離級別為讀已提交的資料庫場景,也可以是其它各種資料庫場景。 This embodiment is similar to the embodiment shown in FIG. 3, except that only the predicted execution data generated by the prediction execution of the locked non-modified database class instruction in the target transaction is recorded, and the prediction execution of the modified database class instruction is generated. The forecast execution data and the forecast execution data generated by the predictive execution of the unblocked non-modified database class instructions are not recorded. In addition, the embodiment is applicable to the case where the target transaction includes the unlocked non-modified database class instruction, and the operated database can be not only the database level with the isolation level being read, but also other database scenarios. .
若將本實施例提供的方法應用於隔離級別為讀已提交的資料庫,則考慮到有些資料庫內定是讀已提交這一隔離級別,例如,Oracle資料庫內定是讀已提交這一隔離級別的,有些資料庫內定不是讀已提交這一隔離級別,例如MySQL資料庫內定是可重複讀這一隔離級別,於是在執 行本實施例提供的方法之前,可以確定資料庫的隔離級別是否是讀已提交,若不是,則需要預先配置資料庫為讀已提交這一隔離級別。例如,可以在應用程式伺服器執行目標事務之前,配置資料庫為讀已提交這一隔離級別。 If the method provided in this embodiment is applied to the database whose isolation level is read, it is considered that some databases are defined as the isolation level that the read has been submitted. For example, the Oracle database defaults to read the submitted isolation level. Some databases do not specify that the isolation level has been read. For example, the MySQL database defaults to the isolation level. Therefore, before executing the method provided in this embodiment, it can be determined whether the isolation level of the database is read. Submitted, if not, you need to pre-configure the repository to read this isolation level. For example, you can configure the repository to read this isolation level before the application server executes the target transaction.
在一可選實施方式中,應用程式伺服器按照現有方式向資料庫發送資料庫操作指令,以實現對資料庫的存取。資料庫操作裝置可以對應用程式伺服器與資料庫之間的通信進行監控,以攔截應用程式伺服器發往資料庫的資料庫操作指令。 In an alternative embodiment, the application server sends a database operation instruction to the database in an existing manner to enable access to the database. The database operating device can monitor the communication between the application server and the database to intercept the database operation instructions sent by the application server to the database.
在另一可選實施方式中,對應用程式伺服器的處理邏輯進行稍微修改,將原來向資料庫發送資料庫操作指令的處理邏輯改為向資料庫操作裝置發送。基於此,資料庫操作裝置可以接收應用程式伺服器主動下發的資料庫操作指令。 In another alternative embodiment, the processing logic of the application server is slightly modified, and the processing logic that originally sent the database operation instruction to the database is changed to be sent to the database operating device. Based on this, the database operating device can receive the database operation instruction actively issued by the application server.
在此說明,若目標事務是顯式事務,則目標事務中的首個指令是事務開始指令,如開始事務(begin transaction),基於此,資料庫操作裝置在獲取應用程式伺服器執行到的資料庫操作指令之前,可以攔截應用程式伺服器發往資料庫的目標事務中的事務開始指令,根據該事務開始指令,獲知需要執行目標事務。或者,資料庫操作裝置在獲取應用程式伺服器執行到的資料庫操作指令之前,可以接收應用程式伺服器主動下發的目標事務中的事務開始指令,根據該事務開始指令,獲知需要執行目標事務。若目標事務是隱式事務,則目標事務的首個指令就是 資料庫操作指令,不包括獲取事務開始指令的步驟。 Here, if the target transaction is an explicit transaction, the first instruction in the target transaction is a transaction start instruction, such as a begin transaction, based on which the database operation device acquires the data executed by the application server. Before the library operation instruction, the transaction start instruction in the target transaction sent by the application server to the database can be intercepted, and according to the transaction start instruction, the target transaction needs to be executed. Alternatively, the database operating device may receive a transaction start instruction in the target transaction actively issued by the application server before acquiring the database operation instruction executed by the application server, and according to the transaction start instruction, learn that the target transaction needs to be executed. . If the target transaction is an implicit transaction, the first instruction of the target transaction is the database operation instruction, and does not include the step of obtaining the transaction start instruction.
資料庫操作裝置在獲取應用程式伺服器執行到的資料庫操作指令後,對獲取到的資料庫操作指令進行預測執行,將預測執行結果返回給應用程式伺服器,以供應用程式伺服器確定下一個需要執行的資料庫操作指令。其中,預測執行結果決定著目標事務的執行路徑,這裡的執行路徑是指資料庫操作指令之間的跳轉邏輯。透過將預測執行結果返回給應用程式伺服器,從而達到由應用程式伺服器控制整個目標事務的執行邏輯的目的。 After obtaining the database operation instruction executed by the application server, the database operation device performs predictive execution on the acquired database operation instruction, returns the predicted execution result to the application server, and determines the supply server program. A database operation instruction that needs to be executed. The predicted execution result determines the execution path of the target transaction, where the execution path refers to the jump logic between the database operation instructions. By returning the predicted execution result to the application server, the purpose of controlling the execution logic of the entire target transaction by the application server is achieved.
另外,資料庫操作裝置還需要在本地記錄所獲取到的資料庫操作指令,以及在該資料庫操作指令屬於被加鎖的非修改資料庫類指令時,記錄對該資料庫操作指令進行預測執行產生的預測執行資料。所述修改資料庫類指令是指對資料庫有修改的資料庫操作指令,例如以update、insert等開頭的指令;一般以select開頭的指令不屬於修改資料庫類指令(稱為非修改資料庫類指令)。有時,為了保證事務的一致性,降低轉返概率,有些非修改資料庫類指令可能需要透過for update語句進行加鎖,例如在上面轉帳舉例中,select指令需要加鎖,形成select......for update形式的資料庫操作指令,這種指令可稱為被加鎖的非修改資料庫類指令。所述預測執行資料主要是指對資料庫操作指令進行預測執行過程中的一些資料,例如資料庫操作指令所操作的資料以及資料的主鍵ID(itemId)和主鍵ID對應的版本號資訊(version)。 In addition, the database operating device also needs to locally record the acquired database operation instruction, and when the database operation instruction belongs to the locked non-modified database type instruction, the record performs prediction execution on the database operation instruction. Forecasted execution data generated. The modified database class instruction refers to a database operation instruction that has a modified database, for example, an instruction that starts with update, insert, etc.; generally, an instruction that starts with a select does not belong to a modified database class instruction (referred to as a non-modified database). Class instruction). Sometimes, in order to ensure the consistency of the transaction and reduce the probability of the return, some non-modified database class instructions may need to be locked by the for update statement. For example, in the above transfer example, the select instruction needs to be locked to form a select... ...for update form database operation instructions, such instructions can be referred to as locked non-modified database class instructions. The predicted execution data mainly refers to some materials in the process of predicting execution of the database operation instruction, such as the data operated by the database operation instruction and the primary key ID (itemId) of the data and the version number information corresponding to the primary key ID (version). .
值得說明的是,對於同一資料庫操作指令來說,要麼屬於修改資料庫類指令,要麼屬於被加鎖的非修改資料庫類指令,要麼屬於未加鎖的非修改資料庫類指令。在該實施例中,對於目標事務中所有被加鎖的非修改資料庫類指令預測執行產生的預測執行資料都會被記錄在本地。 It is worth noting that for the same database operation instruction, it is either a modified database class instruction, a locked non-modified database class instruction, or an unlocked non-modified database class instruction. In this embodiment, the predicted execution data generated for the prediction execution of all locked non-modified repository class instructions in the target transaction is recorded locally.
例如,資料庫操作裝置可以在本地創建記憶體庫,將所獲取到的資料庫操作指令以及預測執行資料存入記憶體庫中。進一步,若預測執行資料不包括預測執行結果,則也可以將預測執行結果存入記憶體庫中。 For example, the database operating device may locally create a memory library, and store the acquired database operation instructions and predicted execution data in a memory library. Further, if the predicted execution data does not include the predicted execution result, the predicted execution result may also be stored in the memory bank.
為了在預測執行這一核心思想的基礎上實現對加鎖方案的模擬,本實施例針對被加鎖的非修改資料庫類指令的資料庫操作指令,記錄其預測執行產生的預測執行資料,卻不記錄其它資料庫操作指令對應的預測執行資料。由此可見,在實現加鎖方案的情況下,所記錄的資料量相對較少,這樣在後續基於本地記錄的資料庫操作指令和預測執行資料在資料庫中真實執行目標事務的過程中,所需處理的資料量相對較少,有利於進一步提高執行效率和性能,增大事務吞吐量。 In order to implement the simulation of the locking scheme on the basis of the core idea of predictive execution, the present embodiment records the predicted execution data generated by the prediction execution for the database operation instruction of the unlocked non-modified database class instruction. The predicted execution data corresponding to other database operation instructions is not recorded. It can be seen that in the case of implementing the locking scheme, the amount of recorded data is relatively small, so that in the subsequent process of executing the target transaction in the database in the database based on the local record-based database operation instruction and the prediction execution data, The amount of data to be processed is relatively small, which is beneficial to further improve execution efficiency and performance, and increase transaction throughput.
較優選的,在資料庫操作指令屬於被加鎖的非修改資料庫類指令時,可以僅記錄該資料庫操作指令所操作的資料的主鍵ID和版本號作為預測執行資料。這樣在後續基於本地記錄的資料庫操作指令和預測執行資料在資料庫中真實執行目標事務的過程中,所需處理的資料量會進一步較少,有利於進一步提高執行效率和性能,增大事務吞吐 量。另外,有時資料在事務過程中可能會經過多次修改,但最終又回到初始值,但資料的主鍵ID和版本號不會發生變化。因此,若採用記錄資料本身的方式,在預測執行與真實執行進行比較時資料可能不一樣,就要發生轉返,而轉返的代價較大。但是,本實施例採用只記錄主鍵ID和版本號的方式,在預測執行與真實執行進行比較時出現不一致的概率較低,轉返概率較低。 Preferably, when the database operation instruction belongs to the locked non-modified database class instruction, only the primary key ID and the version number of the data operated by the database operation instruction may be recorded as the predicted execution data. In this way, in the subsequent process of realizing the target transaction in the database based on the local record-based database operation instruction and the prediction execution data, the amount of data to be processed is further reduced, which is beneficial to further improve the execution efficiency and performance, and increase the transaction. Throughput. In addition, sometimes the data may be modified several times during the transaction, but eventually return to the initial value, but the primary key ID and version number of the data will not change. Therefore, if the method of recording the data itself is used, the data may be different when the forecast execution is compared with the real execution, and the return will occur, and the cost of the return is greater. However, in this embodiment, the method of recording only the primary key ID and the version number is adopted, and the probability of occurrence of inconsistency when the prediction execution is compared with the real execution is low, and the probability of the return is low.
其中,資料庫操作指令對資料庫的操作主要是存取資料庫中的資料,則可以模擬資料庫操作指令的資料環境,基於所模擬的資料環境對資料庫操作指令進行預測執行。進一步,考慮到屬於非修改資料庫類指令的資料庫操作指令不會引起資料庫的變化,因此可以直接在資料庫中對該資料庫操作指令進行預測執行,這樣可以節約模擬資料環境的操作,實現相對簡單,有利於節約資源,提高執行效率。但是,對於屬於修改資料庫類指令的資料庫操作指令,由於其會引起資料庫的變化(主要是指資料庫中的資料被改變),因此需要模擬資料環境,在所模擬的資料環境中進行預測執行。 The operation of the database operation instruction on the database mainly refers to accessing the data in the database, and the data environment of the database operation instruction can be simulated, and the database operation instruction is predicted and executed based on the simulated data environment. Further, considering that the database operation instruction belonging to the non-modified database class instruction does not cause the change of the database, the database operation instruction can be directly predicted and executed in the database, thereby saving the operation of the simulation data environment. The implementation is relatively simple, which is conducive to saving resources and improving execution efficiency. However, for the database operation instruction belonging to the modified database class instruction, since it will cause the database to change (mainly the data in the database is changed), the simulation data environment is required to be performed in the simulated data environment. Forecast execution.
基於上述分析,一種對資料庫操作指令進行預測執行的方式可以是:對獲取到的資料庫操作指令的類別進行識別;若資料庫操作指令屬於修改資料庫類指令,則在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於所模擬的資料環境對資料庫操作指令進行預測執行; 若資料庫操作指令屬於非修改資料庫類指令,在資料庫中執行該資料庫操作指令,以對該資料庫操作指令進行預測執行。 Based on the above analysis, a method for predictive execution of the database operation instruction may be: identifying the category of the obtained database operation instruction; if the database operation instruction belongs to the modification database type instruction, the locally created memory The data environment of the simulation database operation instruction in the library predicts execution of the database operation instruction based on the simulated data environment; if the database operation instruction belongs to the non-modified database type instruction, the database operation instruction is executed in the database, Predictive execution of the database operation instructions.
進一步,一種在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於所模擬的資料環境對資料庫操作指令進行預測執行的實施方式包括:將獲取到的資料庫操作指令拆分為一個讀指令和一個寫指令,將讀指令運行於真正的資料庫上,即在資料庫中執行該讀指令以獲取讀資料集(ReadSet),將讀資料集存入本地記憶體庫中,以模擬資料庫操作指令所需的資料環境。然後,將寫指令作用於記憶體庫上,以實現對資料庫操作指令的預測執行,即在記憶體庫中執行寫指令以修改讀資料集,例如對讀資料集中的有關資料進行更新或查詢處理等。其中,執行寫指令以修改讀資料集可以產生結果資料集(affectRowInMemdb),該結果資料集包括預測執行結果。 Further, a data environment for simulating a database operation instruction in a locally created memory library, and an implementation manner of predicting execution of the database operation instruction based on the simulated data environment includes: splitting the obtained database operation instruction into A read instruction and a write instruction, the read instruction is run on a real database, that is, the read instruction is executed in the database to obtain a read data set (ReadSet), and the read data set is stored in the local memory library, The data environment required to simulate database operations instructions. Then, the write command is applied to the memory bank to implement predictive execution of the database operation instruction, that is, executing a write instruction in the memory bank to modify the read data set, for example, updating or querying related data in the read data set. Processing and so on. Wherein, executing a write command to modify the read data set may generate a result data set (affectRowInMemdb), the result data set including the predicted execution result.
當資料庫操作裝置獲取到目標事務中的事務提交指令(即應用程式伺服器執行到事務提交指令)時,則可以根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務。 When the database operation device acquires the transaction commit instruction in the target transaction (that is, the application server executes to the transaction commit instruction), it can control the corresponding application server according to the locally recorded database operation instruction and the predicted execution data. The database actually performs the target transaction.
上述根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務的一種可選實施方式包括:資料庫操作裝置向資料庫下發本地記錄的資料庫操作 指令,以指示資料庫執行資料庫操作指令,並接收資料庫返回的資料庫操作指令的實際執行結果;然後,將資料庫操作指令的實際執行結果與預測執行結果進行比較,若實際執行結果與預測執行結果相同,向資料庫下發事務提交指令,以供資料庫提交該目標事務;若實際執行結果與預測執行結果不相同,向資料庫下發事務轉返指令,以供資料庫轉返該目標事務。 The above-mentioned optional implementation manner of controlling the database corresponding to the application server according to the locally recorded database operation instruction and the prediction execution data includes: the database operation device sends the local record database operation to the database An instruction to instruct the database to execute the database operation instruction, and receive the actual execution result of the database operation instruction returned by the database; and then compare the actual execution result of the database operation instruction with the predicted execution result, if the actual execution result is The forecast execution result is the same, and the transaction commit instruction is sent to the database for the database to submit the target transaction; if the actual execution result is different from the predicted execution result, the transaction return instruction is sent to the database for the database to be returned. The target transaction.
在上述實施方式中,考慮到事務的原子性,透過將實際執行結果與預測執行結果進行比較,可以避免事務執行過程出錯,有利於提高事務執行的成功概率。 In the above embodiment, considering the atomicity of the transaction, by comparing the actual execution result with the predicted execution result, the transaction execution process error can be avoided, and the success probability of the transaction execution is improved.
進一步,在現有技術中,由於無法預先知道事務需要執行的全部資料庫操作指令,所以只能按照事務的執行邏輯依次執行資料庫操作指令,這會導致應用程式伺服器與資料庫之間的頻繁互動,這在遠程應用場景中將會消耗大量網路資源。但在本實施例中,透過預測執行過程已經預先獲得目標事務需要執行的全部資料庫操作指令,即本地記錄的資料庫操作指令,因此在向資料庫下發本地記錄的資料庫操作指令,以指示資料庫執行資料庫操作指令的過程中,可以將本地記錄的資料庫操作指令同時(或者一併)下發到資料庫,有利於節約網路資源。另外,對於一些並行的資料庫操作指令,資料庫還可以並行操作,有利於進一步提高事務執行效率,增大事務吞吐量。 Further, in the prior art, since all the database operation instructions that the transaction needs to execute cannot be known in advance, the database operation instruction can be executed sequentially according to the execution logic of the transaction, which causes frequent interaction between the application server and the database. This will consume a lot of network resources in the remote application scenario. However, in this embodiment, all the database operation instructions that need to be executed by the target transaction, that is, the local record database operation instruction, have been obtained in advance through the prediction execution process, so that the local record database operation instruction is sent to the database to In the process of instructing the database to execute the database operation instruction, the local record database operation instruction can be simultaneously (or collectively) sent to the database, which is conducive to saving network resources. In addition, for some parallel database operation instructions, the database can also operate in parallel, which is beneficial to further improve transaction execution efficiency and increase transaction throughput.
進一步,還可以將本地記錄的所有資料庫操作指令連同本地記錄的預測執行資料一併下發給資料庫。 Further, all the database operation instructions recorded locally can be sent to the database together with the locally recorded predicted execution data.
進一步,在一種根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務的可選實施方式中,資料庫操作裝置可以根據本地記錄的資料庫操作指令,判斷目標事務是否為單機事務;若判斷結果為是,則根據本地記錄的資料庫操作指令以及預測執行資料,以單機事務處理邏輯控制資料庫實際執行目標事務;若判斷結果為否,則根據本地記錄的資料庫操作指令以及預測執行資料,以分布式事務處理邏輯控制資料庫實際執行目標事務。 Further, in an optional implementation manner of controlling a database corresponding to the actual execution of the target transaction according to the locally recorded database operation instruction and the predicted execution data, the database operation device may operate the instruction according to the locally recorded database. , determining whether the target transaction is a stand-alone transaction; if the determination result is yes, according to the locally recorded database operation instruction and the predicted execution data, the single-machine transaction processing logic controls the database to actually execute the target transaction; if the judgment result is no, then according to The locally recorded database operation instructions and the predicted execution data, and the distributed transaction logic control the database to actually execute the target transaction.
其中,基於預測執行過程中獲得的資料庫操作指令可以識別出目標事務是單機事務還是分布式事務。例如,可以判斷本地記錄的資料庫操作指令的操作對象是否作用於同一實體設備上,若判斷結果為是,則可以確定該目標事務為單機事務;若判斷結果為否,則可以確定該目標事務為分布式事務。 The database operation instruction obtained during the prediction execution process can identify whether the target transaction is a stand-alone transaction or a distributed transaction. For example, it may be determined whether the operation object of the locally recorded database operation instruction acts on the same entity device. If the determination result is yes, the target transaction may be determined to be a stand-alone transaction; if the determination result is negative, the target transaction may be determined. For distributed transactions.
由於分布式事務的處理邏輯和單機事務的處理邏輯有所不同,單機事務的處理邏輯相對簡單,例如不涉及讀寫加鎖等問題,所以所消耗的資源也相對較少。基於此,本實施例透過識別目標事務是否為單機事務,在識別為單機事務時採用單機事務的處理邏輯進行處理,而不是像現有技術那樣統一採用分布式事務處理邏輯進行處理,有利於提高處理效率,節約處理成本。 Because the processing logic of distributed transactions is different from the processing logic of stand-alone transactions, the processing logic of single-machine transactions is relatively simple, for example, it does not involve problems such as read-write and lock, so the resources consumed are relatively small. Based on this, the present embodiment uses the processing logic of the single-machine transaction to identify the target transaction as a single-machine transaction, instead of using the distributed transaction processing logic to process the same as the prior art, which is beneficial to improve processing. Efficiency, saving processing costs.
在一可選實施方式中,若資料庫操作裝置獲取到目標事務中的事務轉返指令(即應用程式伺服器執行到事務轉 返指令)時,可以刪除本地記錄的資料庫操作指令以及預測執行資料,例如可以直接清空本地記憶體庫,實現轉返操作。在該情況下,由於目標事務並未在資料庫中真正執行,所以資料庫無需執行轉返操作,可見,在事務轉返這種情況下,採用本實施例方法也可以提高事務執行效率。 In an optional implementation manner, if the database operation device acquires a transaction return instruction in the target transaction (ie, the application server executes to the transaction return instruction), the local record database operation instruction and the prediction execution may be deleted. For example, the local memory bank can be directly emptied to implement the transfer operation. In this case, since the target transaction is not actually executed in the database, the database does not need to perform the transfer operation. It can be seen that in the case of the transaction return, the transaction efficiency can be improved by using the method of the embodiment.
由上述可見,在本實施例提供的方法中,資料庫操作裝置與應用程式伺服器相互配合,在應用程式伺服器執行目標事務的過程加入預測執行過程,在預測執行過程中,可以提前獲得目標事務的執行路徑,即真正需要執行的資料庫操作指令,並僅針對屬於被加鎖的非修改資料庫類指令的資料庫操作指令記錄預測執行產生的預測執行資料,以適應於加鎖方案,為真實執行事務提供了條件,之後在根據記錄的資料庫操作指令以及預測執行資料實際執行該目標事務時,例如基於預測執行資料可以提前獲取有關資料資訊並且可以減少指令之間的跳轉等,因此可以提高執行效率,增大事務吞吐量。 It can be seen from the above that in the method provided by the embodiment, the database operation device cooperates with the application server to join the prediction execution process in the process of executing the target transaction by the application server, and the target can be obtained in advance during the prediction execution process. The execution path of the transaction, that is, the database operation instruction that really needs to be executed, and only records the prediction execution data generated by the prediction execution for the database operation instruction belonging to the locked non-modified database class instruction to adapt to the locking scheme. Providing conditions for the real execution of the transaction, and then when the target transaction is actually executed according to the recorded database operation instruction and the prediction execution data, for example, based on the prediction execution data, the related information information can be acquired in advance and the jump between the instructions can be reduced, etc., Can improve execution efficiency and increase transaction throughput.
需要說明的是,對於前述的各方法實施例,為了簡單描述,故將其都表述為一系列的動作組合,但是本領域技術人員應該知悉,本發明並不受所描述的動作順序的限制,因為依據本發明,某些步驟可以採用其他順序或者同時進行。其次,本領域技術人員也應該知悉,說明書中所描述的實施例均屬於優選實施例,所涉及的動作和模組並不一定是本發明所必須的。 It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should understand that the present invention is not limited by the described action sequence. Because certain steps may be performed in other sequences or concurrently in accordance with the present invention. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
在上述實施例中,對各個實施例的描述都各有側重, 某個實施例中沒有詳述的部分,可以參見其他實施例的相關描述。 In the above embodiments, the descriptions of the various embodiments are different, and the parts that are not detailed in an embodiment can be referred to the related descriptions of other embodiments.
圖5為本發明又一實施例提供的資料庫操作裝置的結構示意圖。如圖5所示,該裝置包括:獲取模組51、預測執行模組52和控制執行模組53。 FIG. 5 is a schematic structural diagram of a database operating device according to another embodiment of the present invention. As shown in FIG. 5, the device includes an acquisition module 51, a prediction execution module 52, and a control execution module 53.
獲取模組51,用於在應用程式伺服器執行目標事務的過程中,依次獲取應用程式伺服器執行到的目標事務中的資料庫操作指令。 The obtaining module 51 is configured to sequentially acquire a database operation instruction in the target transaction executed by the application server during the execution of the target transaction by the application server.
預測執行模組52,用於對資料庫操作指令進行預測執行,將預測執行結果返回給應用程式伺服器以供應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本地記錄資料庫操作指令以及在資料庫操作指令屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一時記錄預測執行產生的預測執行資料。 The predictive execution module 52 is configured to perform predictive execution on the database operation instruction, return the predicted execution result to the application server to supply the application server to determine the next database operation instruction to be executed, and record the database locally. The operation instruction and the prediction execution data generated by the prediction execution are recorded when the database operation instruction belongs to one of the modified database class instruction and the locked non-modified database class instruction.
控制執行模組53,用於當獲取到目標事務中的事務提交指令時,根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務。 The control execution module 53 is configured to control the database corresponding to the application server to actually execute the target transaction according to the locally recorded database operation instruction and the predicted execution data when the transaction commit instruction in the target transaction is acquired.
在一可選實施方式中,預測執行模組52在資料庫操作指令屬於修改資料庫類指令和被加鎖的非修改資料庫類指令其中之一時記錄預測執行產生的預測執行資料的過程中,具體可用於:在資料庫操作指令屬於被加鎖的非修改資料庫類指令時,僅記錄該資料庫操作指令所操作的資料的主鍵ID和 資料版本號作為預測執行資料。 In an optional implementation manner, the predictive execution module 52 records the predicted execution data generated by the predictive execution when the database operation instruction belongs to one of the modified database class instruction and the locked non-modified database class instruction. Specifically, when the database operation instruction belongs to the locked non-modified database class instruction, only the primary key ID and the data version number of the data operated by the database operation instruction are recorded as the predicted execution data.
在一可選實施方式中,該裝置還包括:配置模組,用於在應用程式伺服器執行目標事務之前,配置資料庫為讀已提交隔離級別。 In an optional implementation, the apparatus further includes: a configuration module, configured to configure the database to read the submitted isolation level before the application server performs the target transaction.
在一可選實施方式中,預測執行模組52具體用於:若資料庫操作指令屬於修改資料庫類指令,在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於模擬的資料環境對資料庫操作指令進行預測執行;若資料庫操作指令屬於非修改資料庫類指令,在資料庫中執行資料庫操作指令,以對資料庫操作指令進行預測執行。 In an optional implementation manner, the prediction execution module 52 is specifically configured to: if the database operation instruction belongs to the modified database class instruction, simulate the data environment of the database operation instruction in the locally created memory library, and the simulation based data The environment performs predictive execution on the database operation instruction; if the database operation instruction belongs to the non-modified database type instruction, the database operation instruction is executed in the database to perform prediction execution on the database operation instruction.
進一步,預測執行模組52在資料庫操作指令屬於修改資料庫類指令的情況下,在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於模擬的資料環境對資料庫操作指令進行預測執行時,具體用於:將資料庫操作指令拆分為讀指令和寫指令;在資料庫中執行讀指令以獲取讀資料集,將讀資料集存入記憶體庫中以模擬資料庫操作指令的資料環境;在記憶體庫中執行寫指令以修改讀資料集。 Further, the predictive execution module 52 simulates the data environment of the database operation instruction in the locally created memory library when the database operation instruction belongs to the modified database type instruction, and performs the database operation instruction based on the simulated data environment. When the prediction is executed, it is specifically used to: split the database operation instruction into a read instruction and a write instruction; execute a read instruction in the database to acquire the read data set, and store the read data set in the memory library to simulate the database operation. The data environment of the instruction; a write instruction is executed in the memory bank to modify the read data set.
在一可選實施方式中,控制執行模組53具體可用於:向資料庫下發本地記錄的資料庫操作指令,以指示資料庫執行資料庫操作指令,並接收資料庫返回的資料庫操作指令的實際執行結果; 若實際執行結果與預測執行結果相同,向資料庫下發事務提交指令,以供資料庫提交目標事務;若實際執行結果與預測執行結果不相同,向資料庫下發事務轉返指令,以供資料庫轉返目標事務。 In an optional implementation, the control execution module 53 is specifically configured to: deliver a locally recorded database operation instruction to the database, instruct the database to execute the database operation instruction, and receive the database operation instruction returned by the database The actual execution result; if the actual execution result is the same as the predicted execution result, the transaction commit instruction is sent to the database for the database to submit the target transaction; if the actual execution result is different from the predicted execution result, the transaction is sent to the database. Return instructions for the database to return to the target transaction.
本實施例提供的資料庫操作裝置,與應用程式伺服器相互配合,在應用程式伺服器執行目標事務的過程加入預測執行過程,預先獲得並記錄目標事務需要執行的全部資料庫操作指令,並僅針對屬於修改資料庫類指令和被加鎖的非修改資料庫類指令的資料庫操作指令,或者僅針對屬於被加鎖的非修改資料庫類指令的資料庫操作指令記錄預測執行產生的預測執行資料,以適應於讀已提交隔離級別下的加鎖方案,為真實執行事務提供了條件,之後根據記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行該目標事務,有利於提高執行效率,進而增大事務吞吐量。 The database operation device provided in this embodiment cooperates with the application server to join the prediction execution process in the process of executing the target transaction by the application server, and obtains and records all the database operation instructions that need to be executed in the target transaction in advance, and only For the database operation instruction belonging to the modified database class instruction and the locked non-modified database class instruction, or only for the database operation instruction belonging to the locked non-modified database class instruction, the prediction execution generated by the prediction execution is recorded. The data is adapted to read the locking scheme under the submitted isolation level, and provides conditions for the real execution of the transaction, and then controls the database corresponding to the application server to actually execute the target according to the recorded database operation instruction and the predicted execution data. Transactions help improve execution efficiency and increase transaction throughput.
圖6為本發明又一實施例提供的資料庫操作裝置的結構示意圖。如圖6所示,該裝置包括:獲取模組61、預測執行模組62和控制執行模組63。 FIG. 6 is a schematic structural diagram of a database operating device according to another embodiment of the present invention. As shown in FIG. 6, the apparatus includes an acquisition module 61, a prediction execution module 62, and a control execution module 63.
獲取模組61,用於在應用程式伺服器執行目標事務的過程中,依次獲取應用程式伺服器執行到的目標事務中的資料庫操作指令。 The obtaining module 61 is configured to sequentially acquire the database operation instruction in the target transaction executed by the application server during the execution of the target transaction by the application server.
預測執行模組62,用於對資料庫操作指令進行預測執行,將預測執行結果返回給應用程式伺服器以供應用程式伺服器確定下一個需要執行的資料庫操作指令,並在本 地記錄資料庫操作指令以及在資料庫操作指令屬於被加鎖的非修改資料庫類指令時記錄預測執行產生的預測執行資料。 The predictive execution module 62 is configured to perform predictive execution on the database operation instruction, return the predicted execution result to the application server to supply the application server to determine the next database operation instruction to be executed, and record the database locally. The operation instruction and the prediction execution data generated by the prediction execution are recorded when the database operation instruction belongs to the locked non-modified database class instruction.
控制執行模組63,用於當獲取到目標事務中的事務提交指令時,根據本地記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行目標事務。 The control execution module 63 is configured to control the database corresponding to the application server to actually execute the target transaction according to the locally recorded database operation instruction and the predicted execution data when the transaction commit instruction in the target transaction is acquired.
在一可選實施方式中,預測執行模組62具體可用於:在資料庫操作指令屬於被加鎖的非修改資料庫類指令時,僅記錄該資料庫操作指令所操作的資料的主鍵ID和版本號作為預測執行資料。 In an optional implementation, the predictive execution module 62 is specifically configured to: when the database operation instruction belongs to the locked non-modified database class instruction, record only the primary key ID of the data operated by the database operation instruction and The version number is used as the forecast execution data.
在一可選實施方式中,該裝置還包括:配置模組,用於在應用程式伺服器執行目標事務之前,配置資料庫為讀已提交隔離級別。 In an optional implementation, the apparatus further includes: a configuration module, configured to configure the database to read the submitted isolation level before the application server performs the target transaction.
在一可選實施方式中,預測執行模組62具體用於:若資料庫操作指令屬於修改資料庫類指令,在本地創建的記憶體庫中模擬資料庫操作指令的資料環境,基於模擬的資料環境對資料庫操作指令進行預測執行;若資料庫操作指令屬於非修改資料庫類指令,在資料庫中執行資料庫操作指令,以對資料庫操作指令進行預測執行。 In an optional implementation manner, the prediction execution module 62 is specifically configured to: if the database operation instruction belongs to the modified database class instruction, simulate the data environment of the database operation instruction in the locally created memory library, and simulate the data The environment performs predictive execution on the database operation instruction; if the database operation instruction belongs to the non-modified database type instruction, the database operation instruction is executed in the database to perform prediction execution on the database operation instruction.
進一步,預測執行模組62在資料庫操作指令屬於修改資料庫類指令的情況下,在本地創建的記憶體庫中模擬 資料庫操作指令的資料環境,基於模擬的資料環境對資料庫操作指令進行預測執行時,具體用於:將資料庫操作指令拆分為讀指令和寫指令;在資料庫中執行讀指令以獲取讀資料集,將讀資料集存入記憶體庫中以模擬資料庫操作指令的資料環境;在記憶體庫中執行寫指令以修改讀資料集。 Further, the prediction execution module 62 simulates the data environment of the database operation instruction in the locally created memory library when the database operation instruction belongs to the modified database class instruction, and performs the database operation instruction based on the simulated data environment. When the prediction is executed, it is specifically used to: split the database operation instruction into a read instruction and a write instruction; execute a read instruction in the database to acquire the read data set, and store the read data set in the memory library to simulate the database operation. The data environment of the instruction; a write instruction is executed in the memory bank to modify the read data set.
在一可選實施方式中,控制執行模組63具體可用於:向資料庫下發本地記錄的資料庫操作指令,以指示資料庫執行資料庫操作指令,並接收資料庫返回的資料庫操作指令的實際執行結果;若實際執行結果與預測執行結果相同,向資料庫下發事務提交指令,以供資料庫提交目標事務;若實際執行結果與預測執行結果不相同,向資料庫下發事務轉返指令,以供資料庫轉返目標事務。 In an optional implementation, the control execution module 63 is specifically configured to: deliver a locally recorded database operation instruction to the database, instruct the database to execute the database operation instruction, and receive the database operation instruction returned by the database The actual execution result; if the actual execution result is the same as the predicted execution result, the transaction commit instruction is sent to the database for the database to submit the target transaction; if the actual execution result is different from the predicted execution result, the transaction is sent to the database. Return instructions for the database to return to the target transaction.
本實施例提供的資料庫操作裝置,與應用程式伺服器相互配合,在應用程式伺服器執行目標事務的過程加入預測執行過程,預先獲得並記錄目標事務需要執行的全部資料庫操作指令,並僅針對屬於被加鎖的非修改資料庫類指令的資料庫操作指令記錄預測執行產生的預測執行資料,以適應於加鎖方案,為真實執行事務提供了條件,之後根據記錄的資料庫操作指令以及預測執行資料,控制應用程式伺服器對應的資料庫實際執行該目標事務,有利於提高執行效率,進而增大事務吞吐量。 The database operation device provided in this embodiment cooperates with the application server to join the prediction execution process in the process of executing the target transaction by the application server, and obtains and records all the database operation instructions that need to be executed in the target transaction in advance, and only Recording the predicted execution data generated by the prediction execution for the database operation instruction belonging to the locked non-modified database class instruction to adapt to the locking scheme, providing conditions for the real execution transaction, and then operating the instruction according to the recorded database and Predicting the execution data and controlling the database corresponding to the application server to actually execute the target transaction is beneficial to improve the execution efficiency and thereby increase the transaction throughput.
所屬領域的技術人員可以清楚地瞭解到,為描述的方便和簡潔,上述描述的系統,裝置和單元的具體工作過程,可以參考前述方法實施例中的對應過程,在此不再贅述。 A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working process of the system, the device and the unit described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本發明所提供的幾個實施例中,應該理解到,所揭露的系統,裝置和方法,可以透過其它的方式實現。例如,以上所描述的裝置實施例僅僅是示意性的,例如,所述單元的劃分,僅僅為一種邏輯功能劃分,實際實現時可以有另外的劃分方式,例如多個單元或組件可以結合或者可以整合到另一個系統,或一些特徵可以忽略,或不執行。另一點,所顯示或討論的相互之間的耦合或直接耦合或通信連接可以是透過一些介面,裝置或單元的間接耦合或通信連接,可以是電性,機械或其它的形式。 In the several embodiments provided by the present invention, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner, for example, multiple units or components may be combined or may be Consolidate to another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical, mechanical or otherwise.
所述作為分離部件說明的單元可以是或者也可以不是實體上分開的,作為單元顯示的部件可以是或者也可以不是實體單元,即可以位於一個地方,或者也可以分佈到多個網路單元上。可以根據實際的需要選擇其中的部分或者全部單元來實現本實施例方案的目的。 The units described as separate components may or may not be physically separated, and the components displayed as the unit may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. . Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本發明各個實施例中的各功能單元可以整合在一個處理單元中,也可以是各個單元單獨實體存在,也可以兩個或兩個以上單元整合在一個單元中。上述整合的單元既可以採用硬體的形式實現,也可以採用硬體加軟體功能單元的形式實現。 In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist as a separate entity, or two or more units may be integrated into one unit. The above integrated unit can be implemented in the form of a hardware or a hardware plus a soft functional unit.
上述以軟體功能單元的形式實現的整合的單元,可以 儲存在一個計算機可讀取儲存媒體中。上述軟體功能單元儲存在一個儲存媒體中,包括若干指令用以使得一台電腦設備(可以是個人電腦,伺服器,或者網路設備等)或處理器(processor)執行本發明各個實施例所述方法的部分步驟。而前述的儲存媒體包括:USB隨身碟、移動硬碟、唯讀記憶體(Read-Only Memory,ROM)、隨機存取記憶體(Random Access Memory,RAM)、磁碟或者光碟等各種可以儲存程式碼的媒體。 The integrated unit described above in the form of a software functional unit can be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform the embodiments of the present invention. Part of the steps of the method. The foregoing storage media include: USB flash drive, mobile hard disk, Read-Only Memory (ROM), Random Access Memory (RAM), disk or CD-ROM, and other storage programs. Code media.
最後應說明的是:以上實施例僅用以說明本發明的技術方案,而非對其限制;儘管參照前述實施例對本發明進行了詳細的說明,本領域的普通技術人員應當理解:其依然可以對前述各實施例所記載的技術方案進行修改,或者對其中部分技術特徵進行等同替換;而這些修改或者替換,並不使相應技術方案的本質脫離本發明各實施例技術方案的精神和範圍。 It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not limited thereto; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that The technical solutions described in the foregoing embodiments are modified, or the equivalents of the technical features are replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (14)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW106102692A TWI805544B (en) | 2017-01-24 | 2017-01-24 | Database operation method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| TW106102692A TWI805544B (en) | 2017-01-24 | 2017-01-24 | Database operation method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| TW201828117A true TW201828117A (en) | 2018-08-01 |
| TWI805544B TWI805544B (en) | 2023-06-21 |
Family
ID=63960251
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| TW106102692A TWI805544B (en) | 2017-01-24 | 2017-01-24 | Database operation method and device |
Country Status (1)
| Country | Link |
|---|---|
| TW (1) | TWI805544B (en) |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP3602840B2 (en) * | 2002-10-22 | 2004-12-15 | 株式会社東芝 | Speculative execution control apparatus and method for instruction |
| US8224845B2 (en) * | 2008-01-21 | 2012-07-17 | International Business Machines Corporation | Transaction prediction modeling method |
| WO2013101147A1 (en) * | 2011-12-30 | 2013-07-04 | Intel Corporation | Configurable reduced instruction set core |
| US9684514B2 (en) * | 2014-09-10 | 2017-06-20 | International Business Machines Corporation | Inference based condition code generation |
-
2017
- 2017-01-24 TW TW106102692A patent/TWI805544B/en active
Also Published As
| Publication number | Publication date |
|---|---|
| TWI805544B (en) | 2023-06-21 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN114270333B (en) | System and method for cardinality estimation feedback loop in query processing | |
| JP6877435B2 (en) | Database operation method and equipment | |
| US11386065B2 (en) | Database concurrency control through hash-bucket latching | |
| US12007992B2 (en) | Serverless data lake indexing subsystem and application programming interface | |
| US11275734B2 (en) | Data lake workload optimization through index modeling and recommendation | |
| EP3396542B1 (en) | Database operating method and device | |
| WO2017041639A1 (en) | Database operating method and device | |
| US12189603B2 (en) | Flexible routing of database operations accessing remote tables | |
| US12380084B2 (en) | Delta transition table for database triggers | |
| TWI774643B (en) | Database operation method and device | |
| EP4542412A1 (en) | Auxiliary query optimizer providing improved query performance | |
| EP4433908A1 (en) | Loading data in a target database system using different synchronization programs | |
| WO2017041637A1 (en) | Database operating method and device | |
| TWI805544B (en) | Database operation method and device | |
| TWI725110B (en) | Database operation method and device | |
| CN107533559A (en) | Data structure, the model for filling data structure and the method being programmed using data structure to processing unit | |
| TWI735512B (en) | Database operation method and device | |
| TWI790991B (en) | Database operation method and device | |
| CN120560788A (en) | Data processing method and related equipment | |
| CN121458215A (en) | Budget data management and analysis system based on multi-mode database cooperation |