The present invention relates to updating a database and more particularly, but not by way of limitation, to a system and methods for updating the structure of a database without restricting a user's access to the database during the update operation.
Databases may be characterized as comprising two types of “objects”—data objects and index objects, both of which are typically embodied as files stored on one or more direct access storage devices (DASD). Data objects and index objects are, in turn, organized and managed through a system catalog or data dictionary (also embodied as files stored on one or more DASD). A system catalog's function is to describe the objects in its database. For example, a system catalog identifies the structure (schema) of each table in its database and any indices associated with those tables. For ease of discussion the following disclosure uses the term ‘table’ to refer to data objects, the term ‘index’ to refer to index objects and the term ‘catalog’ to refer to a database's system catalog.
Referring to
By way of example, consider index rebalance operation 200 outlined in
Next, rebalance process 200 issues a STOP command against the target dataset, or at least those partitions of the target database placed into a restricted state in accordance with block 215 (block 225). Until the restricted status is removed and a start command is issued (see block 240 below), those partitions placed into a restricted state are not accessible to users and any queries and/or commands that require the restricted partitions are failed. Accordingly, a user outage begins once the change command is committed. Those partitions (tables and indices) needing modifications to effect the desired rebalance operation are made (block 230), the restricted state of the modified partitions is released (block 235) and the database restarted (240). Once restarted, user access is restored (i.e., the blockage ends) and normal user queries and/or commands may be processed.
As noted above, some database changes, such as the index rebalance operation of
In one embodiment, the invention provides a method to change the structure (tables and/or indices) of a target database without causing user outages. The method includes receiving a database change command, determining one or more portions of the target database that will be affected by the change command, creating one or more shadow portions of the determined one or more portions, changing the one or more shadow portions in accordance with the change command, executing the change command against the target database and swapping the one or more shadow portions for the determined one or more portions. Methods in accordance with the invention create and change the shadow portions before executing the change command. Methods in accordance with the invention may be stored in any media that is readable and executable by a computer system.
The present invention relates to updating a database and more particularly, but not by way of limitation, to a system and methods for updating the structure of a database without restricting a user's access to the database during the update operation. The following embodiments are described in terms of rebalancing a partitioned DB2® database by specifying a change in Limitkey values through the DB2 ALTER (change) command. These embodiments are illustrative only and are not to be considered limiting in any respect.
Referring to
Update process 300 then re-establishes the lock released during the acts of block 315 (block 320) and sets those partitions of the database placed into a restricted state by the acts of block 315 into an unrestricted state (block 325). The previously updated shadow partitions are then swapped for their associated (but not updated) partitions in the source database (block 330) and the aforementioned acts committed (block 335). Performing the COMMIT has the effect of releasing the lock re-established during the acts of block 320 so that any queued user queries and/or commands against the previously locked partitions can be processed.
It is significant that illustrative update process 300 in accordance with the invention actually obtains and updates the structure of source database partitions in block 310, before the change command is ever executed against the source database in block 315. It is further significant that update process 300 keeps the source database (or portions thereof) out of a restricted state (see block 325). A consequence of these unique features is that a database's structure may be updated without causing a user outage. (It will be recognized and appreciated by those of ordinary skill in the art that use of database locks cause user queries and/or commands to queue so that users do not perceive an outage, while use of restrictive states cause user queries and/or commands to fail which, by definition, is perceived as an outage.)
Referring now to
Continuing the example above, the acts of block 425 involve executing of a pair of DB2 programs for each contiguous group of partitions that were identified during the acts of block 405 as needing to be changed, updated or altered. That is, if the ALTER command of block 305 (see
Referring to
It is noted that in the illustrative DB2 embodiment described above, the act of re-establishing a lock of designated source database partitions (see block 320 in
Referring again to
Referring now to
Methods in accordance with the invention provide a means to change the structure of a database (or portion thereof) without causing a user outage. This beneficial result is achieved by creating shadow copies of a specified portion of a source database's information (e.g., tables and indices), maintaining locks (as opposed to restrictive states) on those portions and then swapping the structurally changed shadow portions for their corresponding source database portions. The use of shadow copies and locks in the manner described herein permit methods in accordance with the invention to avoid the use of restricted states that, by definition, create user outages.
Acts in accordance with
While the invention has been disclosed with respect to a limited number of embodiments directed to a DB2 ALTER command, numerous modifications and variations will be appreciated by those skilled in the art. It is intended, therefore, that the following claims cover all such modifications and variations that may fall within the true sprit and scope of the invention.
| Number | Name | Date | Kind |
|---|---|---|---|
| 5396623 | McCall et al. | Mar 1995 | A |
| 5491818 | Malatesta et al. | Feb 1996 | A |
| 5546536 | Davis et al. | Aug 1996 | A |
| 5613111 | Malatesta et al. | Mar 1997 | A |
| 6035379 | Raju et al. | Mar 2000 | A |
| 6070170 | Friske et al. | May 2000 | A |
| 6192460 | Goleman et al. | Feb 2001 | B1 |
| 6965905 | Garthwaite | Nov 2005 | B2 |
| 20030009436 | Broden et al. | Jan 2003 | A1 |
| 20030135478 | Marshall et al. | Jul 2003 | A1 |
| 20030220938 | Norcott | Nov 2003 | A1 |