Scalable Database Server, HiRDB Version 8 Description

[Contents][Glossary][Index][Back][Next]

6.10.1 Units of locking

This section explains the units of locking and their inclusion relationships.

Organization of this subsection
(1) Locked resources and their inclusion relationships
(2) Setting the lowest-order locked resource unit

(1) Locked resources and their inclusion relationships

HiRDB prevents illegal referencing and updating by applying locks based on a unit called the locked resource. Locking is applied sequentially from top to bottom of the locked resources. If when locking is applied there is a transaction that cannot execute because it is in contention with other transactions for a resource, that transaction goes onto wait status.

Locked resources have inclusion relationships. Therefore, once a lock is applied to a higher-order resource, there is no need to apply locks to the resources that are below it hierarchically. Figure 6-24 shows locked resources and their inclusion relationships. For example, a table is a higher-order resource and a page is a lower-order resource.

Figure 6-24 Locked resources and their inclusion relationships

[Figure]

1 If index key value no-lock is applied, the key value is not locked. For details about index key value no-lock, see the HiRDB Version 8 UAP Development Guide.

2 Logical file used by a plug-in.

(2) Setting the lowest-order locked resource unit

For each table, the user can set the lowest-order locked resource unit for the locking to be applied automatically by HiRDB. The lowest-order locked resource unit, the setting procedures, and their advantages and disadvantages are explained as follows.

(a) Locking by row

To set the row as the lowest-order unit of locking, LOCK ROW is specified in the CREATE TABLE definition SQL. Locking that uses the row as the lowest-order unit of locking is called row locking. Compared to locking by page, locking by row results in better concurrent execution because it is a lower unit of locked resources. On the other hand, locking by row increases the processing time required for locking and increases memory usage.

(b) Locking by page

To set the page as the lowest-order unit of locking, LOCK PAGE is specified in the CREATE TABLE definition SQL. Locking that uses the page as the lowest-order unit of locking is called page locking. Compared to locking by row, locking by page reduces the processing time required for locking and reduces memory usage. On the other hand, locking by page results in poor concurrent execution.