This application is based upon and claims the benefit of priority of the prior Japanese Patent Application No. 2014-194380, filed on Sep. 24, 2014, the entire contents of which are incorporated herein by reference.
The embodiment discussed herein is related to a technique for updating a database.
There is a method for executing collective update so as to add data including a large number of records to a database, as well as a method for individually updating each record in accordance with an access request such as an SQL (that is not an abbreviated word as a standard, but indicates Structured Query Language in some cases) statement.
When the database is to be collectively updated, other update of the database is excluded in order to ensure the matching of an index with data after the update in many cases. For example, the access request such as the SQL statement is limited.
For example, it is desirable that, for a user who uses a database by online transaction processing (OLTP), the processing be continuously executed. A related technique is disclosed in Japanese Laid-open Patent Publication No. 2006-251990, for example.
According to an aspect of the invention, an update method executed by a computer includes: recording a history of processes executed on records in a database in accordance with a request; generating a second index, respectively, for a plurality of new records added to the database in accordance with another request, by applying a storage position to a first index of the plurality of records respectively; and reflecting, to the second index, at least one process from among the processes, the at least one process being executed after a start of the generating of the second index.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention, as claimed.
According to an aspect, a technique disclosed in an embodiment enables individual update to be executed during collective update of a database.
The database management system 105 includes a first receiving unit 203 and an executing unit 205 in order to execute the online transaction processing. The first receiving unit 203 receives the SQL statement through the LAN. The executing unit 205 executes a process based on the received SQL statement.
The database management system 105 also includes a data storage unit 207. The data storage unit 207 stores data included in a database, control data, and the like.
The loader unit 107 executes a process of collectively loading data acquired from another database or another system, for example. The loader unit 107 includes a second interface 209. The second interface 209 is used in order to use direct path loading. In the direct path loading, data is updated at a high speed. For the direct path loading, there is no concept of transactions.
The database management system 105 includes a second receiving unit 211 and a collectively adding unit 213 in order to collectively add data by the direct path loading. The second receiving unit 211 receives a request (hereinafter referred to as add request) to collectively add data, for example. The collectively adding unit 213 collectively adds the data in accordance with the received add request. An example in which multiple records are added to a table of the database managed by the database management system 105 at one time is described below. The database management system 105 also includes a recording processing unit 215. The recording processing unit 215 executes a process of recording an archive and a process of recording a cancellation log.
The database management system 105, the first receiving unit 203, the executing unit 205, the second receiving unit 211, the collectively adding unit 213, and the recording processing unit 215 that are described above are achieved using hardware resources (for example, hardware resources illustrated in
The data storage unit 207 is achieved using a hardware resource (for example, a hardware resource illustrated in
Next, data of the table of the database is described.
Next, the configuration of data of a new table after data is collectively added is described.
Next, a sequence according to the embodiment is described.
During the time when the application unit 109 and the database management system 105 execute the aforementioned online transaction processing, the loader unit 107 transmits an add request 605 to the database management system 105. The database management system 105 collectively adds data in accordance with the received add request 605 and returns results 607 of the collective addition to the loader unit 107.
In the embodiment, data is collectively added without the interruption of the online transaction processing. In the example, a mode of the database management system 105 during the time when a process of collectively adding data is executed is referred to as an addition mode. A mode of the database management system 105 that is not in the addition mode is referred to as a normal mode.
Next, the flow of data in the addition mode is described.
Added data is stored in the added data region 507 (S753). Then, an element string 709 is extracted from the added data (S755). Elements of the element string 709 are pairs of key values and TIDs. The pairs of key values and TIDs are held by nodes of the new leaf node region 509. The key values and the TIDs are associated with each other in the elements in the same manner as the nodes. A procedure for extracting the element string 709 from the added data is the same as or similar to a conventional procedure for generating leaf nodes.
Then, the database management system 105 merges nodes of the existing leaf node region 703 with the elements of the element string 709 and causes the nodes and the elements to be stored in the new leaf node region 509 (in S757). The process of S757 is referred to as a generation process.
In the embodiment, however, the process based on the SQL statement 601 is executed during the merger process. The process that is based on the SQL statement 601 and executed during the merger process is read from the archive log 707 and the new leaf node region 509 is additionally updated together with the processes (S759). The process of S759 is referred to as a reflection process.
Then, the new higher-level node region 511 is generated based on the new leaf node region 509 generated by the generation process and the reflection process (S761). At the stage at which the new higher-level node region 511 is generated, a new index is completed.
The update of at least one of the nodes of the existing leaf node region 703 that is caused by the process that is based on the SQL statement 601 and executed during the generation process is reflected in the new leaf node region 509 in the generation process, while the update of the other nodes of the existing leaf node region 703 that is caused by the process that is based on the SQL statement 601 and executed during the generation process is not reflected in the new leaf node region 509 in the generation process.
The update of the nodes of the existing leaf node region 703 that is caused by the process that is based on the SQL statement 601 and executed during the generation process is described below.
As illustrated in
As illustrated in
Next, an example in which the archive log 707 is applied to the new leaf node region 509 in the reflection process is described with reference to
A record 903 of the archive log 707 is added in a process corresponding to the insertion of the node 805 illustrated in
A record 905 of the archive log 707 is added in a process corresponding to the deletion of the node 807 illustrated in
A record 907 of the archive log 707 is added in a process corresponding to the deletion of the node 803 illustrated in
Even after the new index is completed by the reflection process, the existing index region 701 is used for processes based on SQL statements 601 issued in transactions started before the completion of the new index. Specifically, until all the transactions started before the completion of the new index are completely terminated, the existing index region 701 is set to be valid. By setting the existing index region 701 to be valid, the atomicity of a series of the processes by the transactions started before the completion of the new index is ensured. If the new index is used immediately after the completion of the new index in the transactions started before the completion of the new index, the number of records referenced by the application unit 109 abruptly increases upon the completion of the new index. As a result, preconditions of a process by the application unit 109 are not satisfied and discrepancy occurs. The atomicity indicates that either a state in which the series of processes by the transactions are completely executed or a state in which all the processes by the transactions are not executed is guaranteed.
In the embodiment, processes of handling records of the table, such as a record extraction process and a record insertion process, each have three patterns, and data access is executed in each of the patterns.
Three patterns are described with reference to
As illustrated in
As illustrated in
A process A-1 of the transaction A and a process B-1 of the transaction B are executed using the existing index region 701 since the new index is yet to be completed. In this example, this pattern is referred to as a first pattern.
Return to the description of
Return to
For example, when the added data region 507 is to be accessed in the record extraction process, the extractor references the new index region 503 and accesses the added data region 507, as represented by an arrow 1301. For example, when the added data region 507 is to be accessed in the record insertion process, the inserting unit references the new index region 503 and accesses the added data region 507, as represented by an arrow 1303, and updates the new index region 503, as represented by an arrow 1305.
For example, when the existing data region 505 is to be accessed in the record extraction process, the extractor references the new index region 503 and accesses the existing data region 505, as represented by an arrow 1307. For example, when the existing data region 505 is to be accessed in the record insertion process, the inserting unit references the new index region 503 and accesses the existing data region 505, as represented by an arrow 1309, and updates the new index region 503, as represented by an arrow 1311. In addition, the inserting unit updates the existing index region 701, as represented by an arrow 1313.
Return to the description of
In the embodiment, whether or not duplication of nodes occurs due to the generation process is verified.
If the duplicate nodes exist in the aforementioned manner, the key value “50”, and the number of duplicates that represents “1”, are associated with each other and stored in a duplication list 1401. The key value in the duplication list 1401 represents the duplicate key value.
In the embodiment, whether or not duplication of nodes occurs is verified by the reflection process.
A middle part of
A lower part of
Thus, there are a case where duplication of nodes is removed in the reflection process and a case where duplication of nodes occurs in the reflection process.
As described above, whether or not duplication of nodes occurs is verified through the generation process and the reflection process. If duplication of nodes occurs, the collective addition of data is cancelled. Thus, if the collective addition of data is successful, the uniqueness of the new leaf node region 509 is ensured.
Next, the configuration of the data storage unit 207 is described.
The transaction table is described below.
Next, the control data is described below.
If the current mode 1801 is the “addition mode”, an existing index region pointer 1805, a new index region pointer 1807, and a completion time 1809 of the new index that are included in the control data storage unit 1609 are used. The existing index region pointer 1805 is used when the existing index region 701 is accessed in the addition mode. The new index region pointer 1807 is used when the new index region 503 is accessed in the addition mode. The completion time 1809 of the new index represents the time when the new index region 503 becomes valid.
The operating unit 1911 handles records included in the table. The operating unit 1911 includes a first extracting unit 1913, an inserting unit 1915, a deleting unit 1917, an updating unit 1919, and a determining unit 1921. The first extracting unit 1913 executes the record extraction process. The inserting unit 1915 executes the record insertion process. The deleting unit 1917 executes a record deletion process. The updating unit 1919 executes the record update process. The determining unit 1921 executes a pattern determination process.
The controlling unit 1901, the starting unit 1903, the completing unit 1905, the cancelling unit 1907, the operating unit 1911, the first extracting unit 1913, the inserting unit 1915, the deleting unit 1917, the updating unit 1919, and the determining unit 1921 that are described above are achieved using hardware resources (for example, the hardware resources illustrated in
Next, a process to be executed by the executing unit 205 is described.
Next, the control process for the transaction is described.
Then, the determining unit 1921 executes the pattern determination process (in S2202).
If the determining unit 1921 determines that the current mode 1801 is not the “addition mode” or if the current mode 1801 is the “normal mode”, the determining unit 1921 determines that the current pattern is the normal pattern (in S2305). Then, the pattern determination process is terminated and the process returns to a process of S2203 illustrated in
On the other hand, if the determining unit 1921 determines that the current mode 1801 is the “addition mode”, the determining unit 1921 reads the completion time 1809 of the new index from the control data storage unit 1609 (in S2307). Then, the determining unit 1921 determines whether or not the new index is completed (in S2309). Specifically, the determining unit 1921 determines that the new index is completed if the completion time 1809 of the new index is set. If the completion time 1809 of the new index is yet to be set, the determining unit 1921 determines that the new index is yet to be completed.
If the determining unit 1921 determines that the new index is yet to be completed, the determining unit 1921 determines that the current pattern is the first pattern (in S2311). Then, the pattern determination process is terminated and the process returns to the process of S2203 illustrated in
On the other hand, if the determining unit 1921 determines that the new index is already completed in S2309, the determining unit 1921 reads the start time of the interested transaction from the transaction table storage unit 1605 (in S2313). Then, the determining unit 1921 determines whether or not the start time of the interested transaction is before the completion time 1809 of the new index (in S2315).
If the determining unit 1921 determines that the start time of the interested transaction is before the completion time 1809 of the new index, the determining unit 1921 determines that the current pattern is the second pattern (in S2317). Then, the pattern determination process is terminated and the process returns to the process of S2203 illustrated in
On the other hand, if the determining unit 1921 determines that the start time of the transaction is not before the completion time 1809 of the new index in S2315 or if the start time of the transaction is after the completion time 1809 of the new index, the determining unit 1921 determines that the current pattern is the third pattern (in S2319). Then, the pattern determination process is terminated and the process returns to the process of S2203 illustrated in
Return to the description of
On the other hand, if the first extracting unit 1913 determines that the received SQL statement 601 is not the SELECT statement, the inserting unit 1915 determines whether or not the received SQL 601 is an INSERT statement (in S2207). If the inserting unit 1915 determines that the received SQL 601 is the INSERT statement, the inserting unit 1915 executes the record insertion process (in S2209). The record insertion process is described later with reference to
On the other hand, if the inserting unit 1915 determines that the received SQL statement 601 is not the INSERT statement, the deleting unit 1917 determines whether or not the received SQL statement 601 is a DELETE statement (in S2211). If the deleting unit 1917 determines that the received SQL statement 601 is the DELETE statement, the deleting unit 1917 executes the record deletion process (in S2213). The record deletion process is described later with reference to
On the other hand, if the deleting unit 1917 determines that the received SQL statement 601 is not the DELETE statement, the updating unit 1919 determines whether or not the received SQL statement 601 is an UPDATE statement (in S2215). If the updating unit 1919 determines that the received SQL statement 601 is the UPDATE statement, the updating unit 1919 executes the record update process (in S2217). The record update process is described later with reference to
On the other hand, if the updating unit 1919 determines that the received SQL statement 601 is not the UPDATE statement, the completing unit 1905 determines whether or not the received SQL statement 601 is a COMMIT statement (in S2219). If the completing unit 1905 determines that the received SQL statement 601 is the COMMIT statement, the completing unit 1905 executes the process of completing the transaction (in S2221). The process of completing the transaction is described with reference to
On the other hand, if the completing unit 1905 determines that the received SQL statement 601 is not the COMMIT statement, the cancelling unit 1907 determines whether or not the received SQL statement 601 is a ROLLBACK statement (in S2223). If the cancelling unit 1907 determines that the received SQL statement 601 is the ROLLBACK statement, the cancelling unit 1907 executes the process of cancelling the transaction (in S2225). The process of cancelling the transaction is described later with reference to
On the other hand, if the cancelling unit 1907 determines that the received SQL statement 601 is not the ROLLBACK statement, the process returns to the process of S2201 in this example.
Next, the record extraction process is described.
On the other hand, if the current pattern is determined not to be the first pattern, the process by the first extracting unit 1913 is branched based on whether or not the current pattern is determined to be the second pattern in the pattern determination process of S2202 illustrated in
On the other hand, if the current pattern is determined not to be the second pattern, the process by the first extracting unit 1913 is branched based on whether or not the current pattern is determined to be the third pattern in the pattern determination process of S2202 illustrated in
If the current pattern is determined not to be the third pattern or is determined to be the normal pattern in the pattern determination process of S2202 illustrated in
When the extracted record is returned to the application unit 109, the record extraction process is terminated.
Next, the record insertion process is described.
On the other hand, if the current pattern is determined not to be the first pattern, the process by the inserting unit 1915 is branched based on whether or not the current pattern is determined to be the second pattern in the pattern determination process of S2202 illustrated in
On the other hand, if the current pattern is determined not to be the second pattern, the process proceeds to a process of S2515 illustrated in
Return to the description of the branch in S2515. If the current pattern is determined not to be the third pattern or if the current pattern is determined to be the normal pattern in the pattern determination process of S2202 illustrated in
As described above, when the addition of the record and the addition of the node in any of the patterns are terminated, the recording processing unit 215 records details of the record insertion process in the archive log 707 (in S2529). The data recorded in S2529 is the pair of the key value and TID of the added record and “insertion” as a node operation type. The recording processing unit 215 records details of the process of cancelling the record insertion process in the cancellation log (in S2531). The data recorded in S2531 is the pair of the key value and TID of the added record and “deletion” as a node operation type.
Next, the record deletion process is described.
On the other hand, if the current pattern is determined not to be the first pattern, the process by the deleting unit 1917 is branched based on whether or not the current pattern is determined to be the second pattern in the pattern determination process of S2202 illustrated in
On the other hand, if the current pattern is determined not to be the second pattern, the process proceeds to the process of S2615 illustrated in
Return to the description of the branch in S2615. If the current pattern is determined not to be the third pattern or if the current pattern is determined to be the normal pattern in the pattern determination process of S2202 illustrated in
As described above, when the deletion of the record and the deletion of the node in any of the patterns are terminated, the recording processing unit 215 records details of the record deletion process in the archive log 707 (in S2629). The data recorded in S2629 is the pair of the key value and TID of the deleted record and “deletion” as a node operation type. The recording processing unit 215 records details of the process of cancelling the record deletion process in the cancellation log (in S2631). The data recorded in S2631 is the pair of the key value and TID of the deleted record and “insertion” as a node operation type.
Next, the record update process is described.
Return to the description of the branch in S2701. If the current pattern is determined not to be the first pattern, the process proceeds to a process of S2711 illustrated in
Return to the description of the branch in S2711. If the current pattern is determined not to be the second pattern, the process proceeds to a process of S2725 illustrated in
In addition, the updating unit 1919 references the new index region 503 and adds the record after the update to the new data region 501 or the existing data region 505 (in S2735). In this case, the existing data region 505 or the new data region 501 is identified in accordance with the TID, for example. The updating unit 1919 adds, to the new index region 503, the node that holds the pair of the key value and TID of the added record (in S2737). Then, the updating unit 1919 determines whether or not the record is added to the existing data region 505 (in S2739). If the updating unit 1919 determines that the record is added to the existing data region 505, the updating unit 1919 adds, to the existing index region 701, the node that holds the pair of the key value and TID of the added record (in S2741). On the other hand, if the updating unit 1919 determines that the record is not added to the existing data region 505 or if the record is added to the new data region 501, the node is not added to the existing index region 701. Then, the process proceeds to a process of S2751 illustrated in
Return to the description of the branch in S2725. If the current pattern is determined not to be the third pattern or if the current pattern is determined to be the normal pattern in the pattern determination process of S2202 illustrated in
The updating unit 1919 references the index region of the normal mode and deletes the record before the update from the data region of the normal mode (in S2743). The updating unit 1919 deletes, from the index region of the normal mode, the node that holds the pair of the key value and TID of the deleted record (in S2745). The updating unit 1919 references the index region of the normal mode and adds the record after the update to the data region of the normal mode (in S2747). The updating unit 1919 adds, to the index region of the normal mode, the node that holds the pair of the key value and TID of the added record (in S2749).
As described above, when the deletion of the record, the deletion of the node, the addition of the record, and the addition of the node in any of the patterns are terminated, the recording processing unit 215 records details of the record deletion process in the archive log 707 (in S2751). The data recorded in S2751 is the pair of the key value and TID of the deleted record and “deletion” as a node operation type”. The recording processing unit 215 records details of the process of cancelling the record deletion process in the cancellation log (in S2753). The data recorded in S2753 is the pair of the key value and TID of the deleted record and “insertion” as a node operation type. The recording processing unit 215 records details of the record insertion process in the archive log 707 (in S2755). The data recorded in S2755 is the pair of the key value and TID of the added record and “insertion” as a node operation type. The recording processing unit 215 records details of the process of cancelling the record insertion process in the cancellation log (in S2757). The data recorded in S2757 is the pair of the key value and TID of the added record and “deletion” as a node operation type.
Next, the process of completing the transaction is described.
Next, the process of cancelling the transaction is described.
Next, the collectively adding unit 213 is described.
The storage processing unit 3001 stores the added data in the added data region 507, for example. The switching unit 3003 switches between the modes. The second extracting unit 3005 extracts the element string 709 from the added data. The verifying unit 3007 verifies the uniqueness of the database, for example. The generating unit 3009 executes the generation process. The reflecting unit 3011 executes the reflection process. The determining unit 3013 determines the time when a new index is completed. The standby unit 3015 executes the standby process. The removing unit 3017 removes unwanted data.
The storage processing unit 3001, the switching unit 3003, the second extracting unit 3005, the verifying unit 3007, the generating unit 3009, the reflecting unit 3011, the determining unit 3013, the standby unit 3015, and the removing unit 3017 are achieved using hardware resources (for example, the hardware resources illustrated in
Next, the collective addition process to be executed by the collectively adding unit 213 is described.
The switching unit 3003 switches the current mode to the addition mode (in S3105). In this case, the switching unit 3003 sets “addition mode” in the field for the current mode 1801 in the control data storage unit 1609. The second extracting unit 3005 extracts the element string 709 from the added data (in S3107). The elements extracted in this example include the pairs of the key values and TIDs that are to be added to the new leaf node region 509.
Then, the verifying unit 3007 verifies a uniqueness constraint for the added data (in S3109). Specifically, the verifying unit 3007 determines whether or not two or more of the key values included in the element string 709 are the same.
Then, the verifying unit 3007 determines whether or not the added data satisfies the uniqueness constraint (in S3111). If the element string 709 does not include two or more key values that are the same, the verifying unit 3007 determines that the added data satisfies the uniqueness constraint. On the other hand, if the element string 709 includes two or more key values that are the same, the verifying unit 3007 determines that the added data does not satisfy the uniqueness constraint.
If the verifying unit 3007 determines that the added data does not satisfy the uniqueness constraint, the removing unit 3017 removes the added data region 507 and the new index region 503 (in S3113). In this case, the removing unit 3017 also removes the element string 709. The switching unit 3003 sets the pointer 1803 provided for the index region of the normal mode and included in the control data storage unit 1609 and switches the current mode 1801 to the “normal mode” (in S3115). In this case, the existing index region pointer 1805 included in the control data storage unit 1609 is copied to the pointer 1803 provided for the index region of the normal mode and included in the control data storage unit 1609. The collectively adding unit 213 returns a return value representing a failure to the loader unit 107 (in S3117). Then, the collectively adding unit 213 terminates the collective addition process.
On the other hand, if the verifying unit 3007 determines that the added data satisfies the uniqueness constraint in S3111, the recording processing unit 215 adds a checkpoint to the archive log 707 stored in the archive log storage unit 1603 (in S3119). The checkpoint is used to identify a record after the time when the generation process is started.
Then, the generating unit 3009 executes the generation process (in S3121). The generating unit 3009 merges the nodes of the existing leaf node region 703 with the elements of the element string 709 and generates the new leaf node region 509, as represented by S757 in
The generating unit 3009 determines whether or not the key value indicated by the first pointer is smaller than the key value indicated by the second pointer (in S3305). If the generating unit 3009 determines that the key value indicated by the first pointer is smaller than the key value indicated by the second pointer, the generating unit 3009 adds the node indicated by the first pointer to the new leaf node region 509 (in S3307). Then, the generating unit 3009 determines whether or not the first pointer indicates the end (position of the last node) of the existing leaf node region 703 (in S3309).
If the generating unit 3009 determines that the first pointer indicates the end of the existing leaf node region 703, the generating unit 3009 treats, as a new node, elements from the element indicated by the second pointer to the last element and adds the new node to the new leaf node region 509 (in S3311). Then, the generation process is terminated and the process proceeds to a process of S3201 illustrated in
On the other hand, if the generating unit 3009 determines that the first pointer does not indicate the end of the existing leaf node region 703 in S3309, the generating unit 3009 sets the first pointer to indicate the next node (in S3313). Then, the process returns to the process of S3305.
If the generating unit 3009 determines that the key value indicated by the first pointer is not smaller than the key value indicated by the second pointer in S3305, the process proceeds to a process of S3401 illustrated in
The generating unit 3009 determines whether or not the key value indicated by the second pointer is smaller than the key value indicated by the first pointer (in S3401). If the generating unit 3009 determines that the key value indicated by the second pointer is smaller than the key value indicated by the first pointer, the generating unit 3009 treats, as a new node, an element indicated by the second pointer and adds the new node to the new leaf node region 509 (in S3403). Then, the generating unit 3009 determines whether or not the second pointer indicates the end (position of the last element) of the element string 709 (in S3405).
If the generating unit 3009 determines that the second pointer indicates the end of the element string 709, the generating unit 3009 adds nodes from the node indicated by the first pointer to the last node to the new leaf node region 509 (in S3407). Then, the generation process is terminated and the process proceeds to the process of S3201 illustrated in
On the other hand, if the generating unit 3009 determines that the second pointer does not indicate the end of the element string 709, the generating unit 3009 sets the second pointer to indicate the next element (in S3409). Then, the process returns to the process of S3305 illustrated in
If the generating unit 3009 determines that the key value indicated by the second pointer is not smaller than the key value indicated by the first pointer in S3401 or if the key value indicated by the first pointer is equal to the key value indicated by the second pointer, the generating unit 3009 adds the node indicated by the first pointer to the new leaf node region 509 (in S3411). In addition, the generating unit 3009 treats, as a new node, the element indicated by the second pointer and adds the new node to the new leaf node region 509 (in S3413). Then, the generating unit 3009 adds the key value to the duplication list 1401 (in S3415). The generating unit 3009 sets the number of duplicates to 1 (in S3417). The duplication list 1401 is generated by the processes of S3415 and S3417, as illustrated in
Then, the generating unit 3009 determines whether or not the first pointer indicates the end of the existing leaf node region 703 (in S3501). If the generating unit 3009 determines that the first pointer indicates the end of the existing leaf node region 703, the generating unit 3009 treads, as a new node, elements from the element indicated by the second pointer to the last element and adds the new node to the new leaf node region 509 (in S3503). Then, the generation process is terminated and the process proceeds to the process of S3201 illustrated in
On the other hand, if the generating unit 3009 determines that the first pointer does not indicate the end of the existing leaf node region 703 in S3501, the generating unit 3009 determines whether or not the second pointer indicates the end of the element string 709 (in S3505). If the generating unit 3009 determines that the second pointer indicates the end of the element string 709, the generating unit 3009 adds nodes from the node indicated by the first node to the last node to the new leaf node region 509 (in S3507). Then, the generation process is terminated and the process proceeds to the process of S3201 illustrated in
If the generating unit 3009 determines that the second pointer does not indicate the end of the element string 709 in S3505, the generating unit 3009 sets the first pointer to indicate the next node (in S3509). In addition, the generating unit 3009 sets the second pointer to indicate the next element (in S3511). Then, the process returns to the process of S3305 illustrated in
As illustrated in
The reflecting unit 3011 executes the reflection process (in S3201). The reflecting unit 3011 applies the archive log 707 to the new leaf node region 509 in the reflection process, as represented by S759 in
On the other hand, if the reflecting unit 3011 determines that the node that holds the key value and the TID that match the key value and TID of the identified record does not exist in S3701, the process corresponding to the insertion of the record into the table of the database is yet to be terminated, and the reflecting unit 3011 inserts a node having the same key value and TID as the record (in S3703). This process corresponds to handling of the record 901 illustrated in
Then, the reflecting unit 3011 determines whether or not a node that holds a key value matching the key value of the identified record exists (in S3705). If the reflecting unit 3011 determines that the node that holds the key value matching the key value of the identified record does not exist, the key values are not duplicated, the first subroutine process is terminated, and the process returns to the process of S3611 illustrated in
On the other hand, if the reflecting unit 3011 determines that the node that holds the key value matching the key value of the identified record exists, the key values are duplicated and recorded in the duplication list 1401. Thus, the reflecting unit 3011 determines whether or not the interested key value is already recorded in the duplication list 1401 (in S3707). If the reflecting unit 3011 determines that the interested key value is already recorded in the duplication list 1401, the reflecting unit 3011 adds 1 to the number of duplicates (in S3709).
On the other hand, if the reflecting unit 3011 determines that the interested key value is not recorded in the duplication list 1401, the reflecting unit 3011 adds the key value to the duplication list 1401 (in S3711) and sets, to 1, the number, corresponding to the interested key value, of duplicates (in S3713). The duplication list 1401 is updated by the processes of S3711 and S3713, as represented in the lower part of
Return to the description of
If the reflecting unit 3011 determines that the node that holds the key value and the TID that match the key value and TID of the identified record does not exist, the process corresponding to the deletion of the record from the table of the database is already terminated, the second routine process is terminated, and the process returns to the process of S3611 illustrated in
On the other hand, if the reflecting unit 3011 determines that the node that holds the key value and the TID that match the key value and TID of the identified record exists in S3801, the process corresponding to the deletion of the record from the table of the database is yet to be terminated, and the reflecting unit 3011 deletes the node having the same key value and TID as the identified record (in S3803). This process corresponds to handling of the record 907 illustrated in
The reflecting unit 3011 determines whether or not the key value of the identified record is already recorded in the duplication list 1401 (in S3805). If the reflecting unit 3011 determines that the key value of the identified record is not recorded in the duplication list 1401, the reflecting unit 3011 terminates the second subroutine process, and the process returns to the process of S3611 illustrated in
On the other hand, if the reflecting unit 3011 determines that the key value of the identified record is already recorded in the duplication list 1401 in S3805, the reflecting unit 3011 subtracts 1 from the number, corresponding to the interested key value, of duplicates (in S3807). The reflecting unit 3011 determines whether or not the number of duplicates after subtracting 1 is 0 (in S3809). If the reflecting unit 3011 determines that the number of duplicates after subtracting 1 is 0, the reflecting unit 3011 deletes the record of the interested key value from the duplication list 1401 (in S3811). The duplication list 1401 is updated by the processes of S3807 to S3811, as represented in the middle part of
Return to the description of
On the other hand, if the reflecting unit 3011 determines that the identified record is the last record, the reflection process is terminated and the process returns to the process of S3203 illustrated in
Return to the description of S32. The verifying unit 3007 determines whether or not the number of duplicate key values is 1 or more in the duplication list 1401 (in S3203). If the verifying unit 3007 determines that the number of duplicate key values is 1 or more in the duplication list 1401, the removing unit 3017 removes the added data and the new index (in S3205). Then, the switching unit 3003 sets the pointer 1803 provided for the index region of the normal mode and included in the control data storage unit 1609 and switches the current mode 1801 to the “normal mode” (in S3207). In this case, the existing index region pointer 1805 included in the control data storage unit 1609 is copied to the pointer 1803 provided for the index region of the normal mode and included in the control data storage unit 1609. The collectively adding unit 213 returns a return value representing a failure to the loader unit 107 (in S3209). Then, the process returns to the process of S3101 illustrated in
On the other hand, if the verifying unit 3007 determines that the number of duplicate key values is not 1 or more in the duplication list 1401 in S3203, the verifying unit 3007 executes a cancellation verification process (in S3210). If the cancellation log is applied by the rollback in the transaction cancellation process, the verifying unit 3007 verifies whether or not duplication of nodes occurs in the new leaf node region 509. Specifically, the verifying unit 3007 verifies whether or not the new leaf node region 509 after the rollback satisfies the uniqueness constraint.
When the record 3901 is applied to the new leaf node region 509, the node that holds the key value “120” and the TID “3900” is added to the new leaf node region 509. However, since a node that holds the key value “120” and a TID “14000” already exists in the new leaf node region 509, the nodes that hold the same key value “120” are duplicated. In the example illustrated in
In the new leaf node region 509, the node that holds the key value “110” and the TID “3500” exists. When the record 3903 is applied to the new leaf node region 509, the node that holds the key value “110” and the TID “3500” is deleted from the new leaf node region 509. In this application example, duplication of nodes does not occur. In the example illustrated in
When the record 3905 is applied to the new leaf node region 509, the node that holds the key value “130” and the TID “4100” is added to the new leaf node region 509. Since a node that holds the key value “130” does not exist in the new leaf node region 509, duplication of nodes does not occur.
Regarding the application of the cancellation log, as illustrated in the application example of the record 3901, when the cancellation process is executed to insert a node in the new leaf node region 509 or the cancellation process of which a node operation type is “insertion” is executed, duplication of nodes may occur. The cancellation verification process is executed to verify whether or not duplication of nodes occurs.
If the verifying unit 3007 determines that the node operation type of the identified record is “insertion”, the verifying unit 3007 determines whether or not a node that holds the same key value as the interested record exists in the new leaf node region 509 (in S4005).
If the verifying unit 3007 determines that the node that holds the same key value as the interested record exists in the new leaf node region 509, the verifying unit 3007 determines that duplication of nodes occurs (in S4007). When the cancellation verification process is terminated, the process returns to the process of S3211 illustrated in
On the other hand, if the verifying unit 3007 determines that the node operation type of the identified record is not “insertion” in S4003 or if the node operation type of the interested record is “deletion”, the verifying unit 3007 determines whether or not an unprocessed record exists in the cancellation log (in S4009).
If the verifying unit 3007 determines that the node that holds the same key value as the key value of the interested record does not exist in the new leaf node region 509 in S4005, the verifying unit 3007 determines whether or not the unprocessed record exists in the cancellation log (in S4009).
If the verifying unit 3007 determines that the unprocessed record exists in the cancellation log, the process returns to S4001, and the aforementioned processes are repeated.
On the other hand, if the verifying unit 3007 determines that the unprocessed record does not exist in the cancellation log, the verifying unit 3007 determines whether or not duplication of nodes do not occur (in S4011). When the cancellation verification process is terminated, the process returns to the process of S3211 illustrated in
Return to the description of
Subsequently, the standby unit 3015 executes the standby process (in S3213). The standby process causes the reflection process to stand by until all the transactions started before the completion of the new index are completely terminated. The standby process causes the reflection process to be executed again when all the transactions are completely terminated.
Then, the standby unit 3015 determines whether or not all operations of the transactions identified in S4101 are terminated (in S4103). Specifically, if “completion” or “cancellation” is set in the records corresponding to the interested transactions in the status field in the transaction table storage unit 1605, the standby unit 3015 determines that the operations of the interested transaction are terminated. If an operation of any of the identified transactions is yet to be terminated, the process of S4103 is repeated. When all the operations of the identified transactions are terminated, the standby process is terminated and process returns to S3215 illustrated in
Return to the description of
According to the embodiment, since even the update of an index by the individual update during the generation process is reflected in a new index through a history, the individual update is executed even during the collective update.
In addition, it is possible to ensure the atomicity of transactions started before the completion of the new index.
In addition, it is possible to inhibit duplication in the new index.
In addition, it is possible to ensure the uniqueness of the database after the collective update.
Furthermore, it is possible to guarantee the uniqueness of the database for a rollback.
The embodiment is described above, but is not limited to this. The aforementioned functional block configuration may not match a program module configuration.
The configurations of the aforementioned storage regions are an example and may not be the same as the aforementioned configurations. In addition, the orders in which the processes are executed may be changed in the process flows as long as the results of the processes are the same as described above. Furthermore, two or more of the processes may be executed in parallel as long as the results of the processes are the same as described above.
The aforementioned database server 101 is a computer device and includes a memory 2501, a central processing unit (CPU) 2503, a hard disk drive (HDD) 2505, a display controller 2507, a driving device 2513, an input device 2515, and a communication controller 2517 that are connected to each other through a bus 2519, as illustrated in
The embodiment is summarized as follows.
The update method according to the embodiment includes recording a history of details of the update of individual records of the database, extracting storage positions of a plurality of records from update data to be used to collectively update the plurality of records of the database, generating a second index in which the extracted storage positions of the records are applied to a first index in the database, and reflecting, in the second index, at least details of the update that are after the start of the generation of the second index and are included in the history.
When the update of the individual records of the database after the start of the generation of the second index is reflected in the second index through the history, the individual update may be executed even during the collective update of the database.
A process of updating the first index and the second index together with the update of the individual records after the completion of the second index until transactions started before the completion of the second index are terminated may be included.
It is, therefore, possible to guarantee the atomicity of the transactions started before the completion of the second index.
A log to be used to execute a rollback for the details of the update may be recorded. In addition, when the rollback is executed based on the log, whether or not duplication of key values occurs may be verified.
In this case, it is possible to inhibit the duplication in the second index.
In the generation process, the storage positions of the records and key values of the records may be extracted and applied to the first index, and whether or not duplication of key values occurs in the second index may be detected. In the reflection process, whether or not duplication of key values occurs due to the application of details of update may be detected. A process of determining that the second index is completed if the duplication of the key values does not occur may be included.
In this case, it is possible to ensure the uniqueness of the database after the collective update.
In the recording process, the log to be used to execute the rollback may be recorded. A process of verifying whether or not duplication of key values occurs when the rollback is executed may be included.
In this case, it is possible to guarantee the uniqueness of the database for the rollback.
A program that causes a computer to execute the process by the aforementioned method may be generated and stored in a storage device or a computer-readable storage medium such as a flexible disk, a CD-ROM, a magnetic optical disc, a semiconductor memory, or a hard disk, for example. Intermediate results of the process may be temporarily stored in a storage memory such as a main memory in general.
All examples and conditional language recited herein are intended for pedagogical purposes to aid the reader in understanding the invention and the concepts contributed by the inventor to furthering the art, and are to be construed as being without limitation to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although the embodiment of the present invention has been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
2014-194380 | Sep 2014 | JP | national |