Professional Documents
Culture Documents
Lock Matrix
Type of Request Lock Mode Lock Target Conflicts/Notes
Initialization parameters None None No locks on reads
Lock table in Row Share Mode 2 TM(RS) lock on table Mode 6, so no exclusive
mode DDL (this is the least
restrictive lock.)
Select for update Mode 2 TM (RS) lock on table Mode 6 and any selects for
Mode 2 TM (RS) lock on each update or DML on same
table partition rows
Mode 6 TX lock on RBX TX No exclusive DDL
slot
Lock table partition in Mode 3 TM (RX) lock on table Modes 4, 5, 6 on the same
Row Exclusiving mode Mode 3 TM (RX) lock on table partition
partition Updates allowed, because
mode 3 does not conflict
with mode 3
No share locks and no
referential integrity locks
Delete from/update to Mode 3 TM(RX) lock on parent Mode 4,5,6 and any selects
parent table with Mode 6 TX lock on RBS TX for update or DML on same
referential integrity slot rows against parent
constraint on child with Updates against rows in
index on FK column in child referred to by DML
child table and no ON against parent
DELECT CASCADE in
the FK constraint
Lock table in Share Row Mode 5 TM(SRX) lock on table Mode 3,4,5,6
Exclusive mode Allows Select for Update
only
No Share locks
No ORA 1555
No cascaded deletes
Delete from/update to Mode 3 TM(RX) lock on parent Mode 4,5,6 and any selects
parent table with Mode 3 TX lock on RBS TX for update or DML on same
referential integrity Mode 6 slot rows against parent
constraint on child table Mode 4,5,6 and any selects
and with index on FK for update or DML or other
column in child table and cascaded deletes on same
with ON DELETE in the rows in child that are current
FK constraint targets for cascaded deletes.
Lock table partition in Mode 3 TM(X) lock on table Mode 2,3,4,5,6 on the same
Exclusive mode Mode 6 TM(X) lock on table partition
partition Mode 5 on any partition
No exclusive DDL
Most restrictive lock mode
on partition
Drop, Truncate, ADD Mode 3 TM(X) lock on table Mode 2,3,4,5,6 on the same
Partition DDL Mode 6 TM(X) lock on table partition
No wait partition Mode 5 on any partition
DDL fails if any other lock
mode on table partition due
to no wait
Shared
Oracle server server
code program processes
interface
Characteristics
The Oracle shared server provides a way for users to share processes and is meant for scaling
up the number of connections that Oracle server can handle concurrently.
The Oracle shared server supports both multiplexing and pooling for user connections by
means of Connection Manager and Connection Pooling.
Without shared servers, each user on a standard UNIX system or a remote client user needs a
dedicated server process to access Oracle server files and memory structures. In an
interactive application, where users spend much of their time talking to customers, these
dedicated servers are mainly idle. They have work to do only when the user sends a query or
a change to the database.
With Oracle shared servers, multiple users can share dispatcher processes, which access the
Oracle Server for them. Oracle uses shared servers to process the SQL statements passed in
by the dispatchers.
Oracle shared server is useful on:
• Systems that have a high overhead for a dedicated server
• Machines that are approaching limits on resources
There is no advantage in using shared servers for database-intensive work. Heavy or batch
users should have dedicated servers.
Troubleshooting
Troubleshooting the Oracle shared server environment is a key DBA function. Some
common problems include the following:
• If the Oracle Net listener is not running, all attempts at shared connections fail. You
need to bring it up whenever the machine is started up.
• Any Oracle Net configuration error gives a TNS_ error message when you try to
establish a shared connection.
• It is always bad practice to kill a user’s server process at the operating system level (use
the ALTER SYSTEM KILL SESSION command instead). But if a user is connected
through a dispatcher, it is even more dangerous, because killing the dispatcher may
affect many other users as well.
• You cannot perform privileged operations such as STARTUP and SHUTDOWN using a
shared server. Make sure you have a dedicated connection for yourself as DBA.
• Your servers and dispatchers count as background processes for the instance. Be careful
that your setting of PROCESSES allows for all possible servers and dispatchers, or new
users may not be able to log in. Setting MTS_MAX_SERVERS and
MTS_MAX_DISPATCHERS can act as a useful ceiling.
• If the parameters (INSTANCE_NAME, SERVICE_NAMES or DB_DOMAIN) are not set
or if they are set to an incorrect value, then the automatic instance registration will not
work.
Oracle9i Performance Tuning 11-11
Obtaining Dictionary Information
Partitioned
table
Definition of Clusters
A cluster is a group of one or more tables that share the same data blocks because they share
common columns and are often used together in join queries. Storing tables in clusters allows
a DBA to denormalize data that is transparent to the end user and programmer.
Performance Benefits of Clusters
• Disk I/O is reduced and access time improved for joins of clustered tables.
• Each cluster key value is stored only once for all the rows of the same key value; it
therefore, uses less storage space.
Performance Consideration
Full table scans are generally slower on clustered tables than on nonclustered tables.
Hash function
Index Clusters
An index cluster uses an index, known as the cluster index, to maintain the data within the
cluster. The cluster index must be available to store, access, or maintain data in an index
cluster.
The cluster index is used to point to the block that contains the rows with a given key value.
The structure of a cluster index is similar to that of a normal index.
Although a normal index does not store null key values, cluster indexes store null keys. There
is only one entry for each key value in the cluster index. Therefore, a cluster index is likely to
be smaller than a normal index on the same set of key values.
Hash Clusters
A hash cluster uses a hash algorithm (either user-defined or system-generated) to calculate
the location of a row, both for retrieval and for DML operations.
For equality searches that use the cluster key, a hash cluster can provide greater performance
gains than an index cluster, because there is only one segment to scan (no index access is
needed).
Index entry
Root
Branch
Key Compression
Specify COMPRESS to enable key compression, which eliminates repeated occurrence of key
column values and may substantially reduce storage. Use integer to specify the prefix length
(number of prefix columns to compress). For unique indexes, the valid range of prefix length
values is from 1 to the number of key columns minus 1 (the default value).
For nonunique indexes, the valid range of prefix length values is from 1 to the number of key
columns. The default prefix length is the number of key columns.
Key compression is useful in many different scenarios, such as:
• In a nonunique regular index, Oracle stores duplicate keys with the row ID appended to
the key to break the duplicate rows. If key compression is used, Oracle stores the
duplicate key as a prefix entry on the index block without the row ID. The rest of the
rows are suffix entries that consist of only the row ID.
• This same behavior can be seen in a unique index that has a key of the form (item, time
stamp), for example, stock_ticker, or transaction_time. Thousands of rows
can have the same stock_ticker value, with transaction_time preserving
uniqueness. On a particular index block, a stock_ticker value is stored only once
as a prefix entry. Other entries on the index block are transaction_time values
stored as suffix entries that refer to the common stock_ticker prefix entry.
In some cases, however, key compression cannot be used. For example, in a unique index with
a single attribute key, key compression is not possible because there is a unique piece, but there
are no grouping pieces to share.
Oracle9i Performance Tuning 12-13
Bitmap Indexes
Table File 3
Block 10
Block 11
Index Block 12
Block 13
Start End
Key ROWID ROWID Bitmap
<Blue, 10.0.3, 12.8.3, 1000100100010010100>
<Green, 10.0.3, 12.8.3, 0001010000100100000>
<Red, 10.0.3, 12.8.3, 0100000011000001001>
<Yellow, 10.0.3, 12.8.3, 0010001000001000010>
Bitmap Indexes
With bitmap indexes, you can store data that has few distinct values within the column, such
as gender or job_title. The index consists of a range of rows stored in the index, and
then a map of binary values for each key. The value is “on”, that is 1, if the key is true for
that row. In the example on the slide, the value in the bitmap is on for only one color. The
row item is blue, then the value is a 1 for blue, and 0 for all other combinations.
Bitmap indexes perform best when there are few variations for the value, but millions of
rows. Bitmap indexes also help resolve Boolean type constraints; for example, if the user
requires all items that are blue and yellow, or if items colored green or red are wanted.
DML statements do not perform well with bitmap indexes, so for high DML activity, do not
use a bitmap index.
Maintenance Considerations
In a data warehousing environment, data is usually maintained by way of bulk inserts and
updates. Index maintenance is deferred until the end of each DML operation. For example, if
you insert 1,000 rows, then the inserted rows are placed into a sort buffer, and then the
updates of all 1,000 index entries are batched. (This is why SORT_AREA_SIZE must be set
properly for good performance with inserts and updates on bitmap indexes.) Thus, each
bitmap segment is updated only once per DML operation, even if more than one row in that
segment changes.
In Oracle9i, there are different parameters affecting the sort area depending on the value of
WORKAREA_SIZE_POLICY. See the chapter titled “Optimizing Sort Operations” for more
details.
Definition
Creating a reverse key index reverses the bytes of each column key value, keeping the
column order in case of a composite key.
When to Create Reverse Key Indexes
An ever-increasing key (such as sequential numbers for invoices, employees, or order
numbers) repetitively degrades the index height (BLEVEL statistic); you can avoid forced
block splits by spreading the index entries more evenly.
Disadvantage
When application statements specify ranges, the explain plan produces a full table scan,
because the index is not usable for a range scan.
ROWID
Non-key columns
Key column
Row header
Definition
An index-organized table is like a regular table with an index on one or more of its columns,
but instead of maintaining two separate segments for the table and the B-tree index, the
database system maintains one single B-tree structure that contains both the primary key
value and the other column values for the corresponding row.
Index-organized tables are suitable for frequent data access through the primary key, or
through any key that is a prefix of the primary key, such as in applications that use inverted
indexes. These indexes keep the value and all its locations together. Each word has one entry,
and that entry records all the places in which the word occurs, and therefore the index could
be used to recreate the document. These indexes are used in Intermedia.
For index-organized tables, a primary key constraint is mandatory.
Benefits
• No duplication of the values for the primary key column (index and table columns in
indexed tables), therefore less storage is required
• Faster key-based access for queries involving exact match or range searches, or both.
DBA_TABLES
The IOT_TYPE and IOT_NAME columns provide information about index-organized tables.
If there is no overflow area for an IOT, then there is only a single dictionary entry. The value
of IOT_TYPE is IOT, and the IOT_NAME field is blank. If an overflow area has been
specified, then its name appears as an additional new table in the list of table names. The
overflow table is called SYS_IOT_OVER_nnnn (where nnnn is the object ID of the table
segment) in DBA_TABLES. IOT_TYPE is set to IOT_OVERFLOW for this table, and
IOT_NAME is set to the name of the index-organized table to which it belongs.
DBA_INDEXES
The IOT table name listed is the same as that used in the CREATE TABLE command, but an
index name is also listed for the table, with a default name of SYS_IOT_TOP_nnnn.
DBA_SEGMENTS
The name of the overflow segment is listed here with the same name as mentioned above,
SYS_IOT_TOP_nnnn. The table itself is listed as SYS_IOT_TOP_nnnn.
Materialized Views
A materialized view stores both the definition of a view and the rows resulting from the
execution of the view. Like a view, it uses a query as the basis, but the query is executed at
the time the view is created and the results are stored in a table. You can define the table with
the same storage parameters as any other table and place it in the tablespace of your choice.
You can also index and partition the materialized view table, like other tables, to improve the
performance of queries executed against them.
When a query can be satisfied with data in a materialized view, the server transforms the
query to reference the view rather than the base tables. By using a materialized view,
expensive operations such as joins and aggregations do not need to be re-executed by
rewriting the query against the materialized view.