 |
|
Basic Direct Access Method (BDAM)
Oracle Tips by Burleson Consulting |
As more data was being stored on
disks, the direct access technique began to become more popular.
Unlike physical sequential, the BDAM (pronounced bee-damn) method uses
a symbolic key, (which is usually a part of the record that is being
stored) The BDAM hashing algorithm will compute the target location of
the record on the disk and then tell the access method to get the
record at that location. Since we can go directly to the record, BDAM
provides much faster access and retrieval of records. A direct access
file is sometimes called a “keyed” file because the key is used to
generate the disk address (Figure 2-2).
Figure 2-2 Hashed file storage
Just as your home address uniquely identifies
where you live, a disk address identifies where a record lives on the device. A
disk address includes the disk number, cylinder address, the track, and the
block address. To find a record in a direct access file, the program must have
a key provided so that it can determine the record address and then retrieve
the desired record, regardless of all the other records in the file. This was
the first time that there had been a separation between the physical access
methods and the logical access methods. That is, the record could be retrieved
simply by providing the key field, and the user need not be concerned with where
the record was physically located on the disk.
Unfortunately, the range of addresses which were
generated by the hashing algorithm required careful management. A hashing
algorithm has to be repeatable, in that the same key always returns the same
disk address. BDAM has to be able to store a record with the hashing algorithm
and be able to retrieve the record using the same algorithm.
Of course, duplicate keys must be avoided. The
duplication of disk addresses leads to “collisions” whereby the hashing
algorithm cannot differentiate between two records. Hence, it is critical that
a unique key be created for each and every record in the file. If a single
field cannot uniquely identify the records, then a combination of fields or
portions of fields can be used. Ever see the code on a magazine subscription
label? These are called “concatenated” keys, and they contain pieces of fields
in the base record, such as the first four letters of the subscriber’s last
name, and a portion of the zip code. Fortunately, there are many ways to
generate unique keys.
BDAM file structures also consume a large amount
of disk storage. BDAM files do not make efficient use of disk storage since
records are randomly distributed across the disk device. Consequently, it is
common to see hashed files with more unused spaces than occupied space see
Figure 2-3.
Figure 2-3 The random distribution of BDAM
records
In most cases, a BDAM file is considered
"logically" full if more than 70 percent of the disk storage space contains data
records. The upper and lower address limits for BDAM can be controlled, such
that records can be stored on a single cylinder, a group of cylinders, or a
group of disk devices.
Despite the problems of space usage and unique
keys, hashing remains one of the fastest ways to store and retrieve
information. Almost all mainframe systems can take a symbolic key and convert
it into a disk storage address in as little as 50 milliseconds. Although
hashing is a very old technique, it is still an extremely powerful method. Many
C++ programmers use hashing to store and retrieve records within their
object-oriented applications and database objects require the definition of an
object ID (OID), which is the unique address of the database object.
 |
If you like Oracle tuning, see the book "Oracle
Tuning: The Definitive Reference", with 950 pages of tuning tips and
scripts.
You can buy it direct from the publisher for 30%-off and get
instant access to the code depot of Oracle tuning scripts. |