Understanding the Locking System

This chapter describes how the locking system works. Ingres is a concurrent database system, which means it allows multiple users to access the same data at the same time. The purpose of this chapter is to provide you with the knowledge you need to maximize concurrent performance and analyze associated problems.

The chapter describes modes and levels of locks, how long locks are held, locking examples, locking parameters and the set lockmode statement, how to avoid deadlock situations, how to monitor locks, and how to improve concurrency.

Previous Topic

Next Topic

Concurrency and Consistency

In any database management system with multiple users, there is a trade-off between concurrency and consistency. Ideally, you want all users to be able to access any data at virtually any time (concurrency) but you must ensure that changes to the database are done in an orderly sequence that maintains the underlying structure of the data (consistency).

The task of the locking system is to manage access to resources shared by user databases, tables, and pages to guarantee the consistency of the shared data. Various types of locks are used to ensure that the database does not become inconsistent through concurrent accesses.

Previous Topic

Next Topic

Locking System Configuration

The locking system works with the Ingres DBMS Server to coordinate access to databases.

The system administrator initially configures the locking system during installation by setting parameters. The locking parameters are installation-wide. They can be changed after installation only by the system administrator.

On UNIX systems, shared memory and semaphores are used as resources during lock control. The shared memory and semaphores used by your installation are configured in the operating system when the UNIX kernel is configured.

For more information, see the System Administrator Guide.

Previous Topic

Next Topic

Lock Types

The locking system grants two types of locks:

Previous Topic

Next Topic

Lock Modes

A lock has a mode that determines its power—for example, whether it prevents other users from reading, or only from changing, the data.

The six lock modes are as follows:

Previous Topic

Next Topic

Lock Levels

Locks can be of several levels. The level of a lock refers to the scope of the resource on which the lock is requested or used, for example, whether the lock affects:

The levels of locks subject to user control are row, page and table. Queries and commands use other lock levels that affect concurrency, such as database and table control locks.

Lock levels are as follows:

Note: We recommend that you be aware of what resources you lock during application development, database maintenance, and ad hoc queries.

For details on the set lockmode operation and user-controlled locking, see User-Controlled Locking. For details on the set lockmode statement syntax, see the SQL Reference Guide.


© 2007 Ingres Corporation. All rights reserved.