HP engineer outlines IMAGE B-tree technical capabilities
Editor's note: HP database engineer Bharati Desai has gathered a
good deal of the input from customers during the past year to help create
the new B-tree indexes in TurboIMAGE. Her article here is taken from the
newsletter of SIGIMAGE, a special interest group of users of TurboIMAGE and
IMAGE/SQL. Any customer making use of an HP 3000 and IMAGE should belong to
SIGIMAGE -- it's the best way to have input on IMAGE enhancements like
B-trees. Membership in SIGIMAGE is free. To join, call Leah Robertson at
Interex, at 408.747.0947, or send e-mail to sigs@interex.org.
By Bharati V. Desai
HP CSY Lab
The need for generic key searches and range searches has been recognized by
IMAGE customers for some time. This is why the request for B-trees in
IMAGE/SQL has consistently been the most desired enhancement of the
SIGIMAGE list.
Continuing with the prevailing tradition in the IMAGE Lab, the input for
the external design of B-trees was obtained from several customers during
(and after) IPROF '96. We believe that the final implementation addresses
the primary needs of the majority of our IMAGE customers. Our objective has
been to provide this new feature and give you as much flexibility as
possible to control the use of it. Enhancements include:
- You can create a B-tree only for the key item of a master dataset.
Nevertheless, you are able to perform a B-tree search for all of its
corresponding detail sets as well. A master dataset is perceived as having
an explicit B-tree and a detail dataset is perceived as having an implicit
B-tree for each of its paths.
- You may create B-tree indices for zero, one, or more master datasets.
- DBSCHEMA introduces a new option, INDEXED, for the "set" specification.
- DBUTIL introduces new commands and options.
- New ADDINDEX, DROPINDEX, and REBUILDINDEX commands (to be used for
one, more than one or all masters).
- The SET command allows you to define your own wildcard character to
indicate "match any trailing text". The default wildcard character is "@".
The concept of "#" and "?" (for single numeric and alphanumeric character,
respectively) is not available. You can specify a generic search using this
wildcard character as part of your DBFIND argument when the search item has
a B-tree (explicit or implicit).
- A new option, BTREEMODE1, for the SET command to set DBFIND mode 1
access ON or OFF for a B-tree search for X and U types. The default is OFF,
in which case DBFIND mode 1 will continue to work the way it does
currently, even when the argument contains a wildcard character. When
BTREEMODE1 is ON, DBFIND mode 1 (with a wildcard character in the argument)
will be treated as a B-tree search.
- The CREATE, ERASE, PURGE, SECURE, RELEASE, MOVE and SHOW commands
include B-tree files in their operation.
- DBCONTROL additions, including Mode 13, are used with the qualifier to
allow privileged-mode (PM) applications to create and maintain B-tree
indices; Mode 15 is used to set the BTREEMODE1 option to "on" on a
database-wide basis and to specify the wildcard character, and Mode 16,
which sets the BTREEMODE1 option "off" on a database-wide basis.
- DBINFO changes include Mode 209, which informs whether or not a B-tree
index exists for a master, and Mode 113, which gives you the BTREEMODE1
setting and the wildcard character.
- DBPUT/DBDELETE to an indexed master triggers a similar operation to
the indexed master's B-tree file.
- DBFIND can be used for details as well as for masters to specify
B-tree searches.
- For wildcard (generic) searches, the wildcard has to be the
terminating character in the argument. Character(s) beyond that will be
ignored.
- If BTREEMODE1 is ON, DBFIND mode 1 will result in a B-tree
search if:
- the dataset has a B-tree index;
- the item is of type X or U; or
- there is a wildcard character in the argument.
- DBFIND introduces new modes 4, 10, 21 and 24. Modes 4 and 24 offer a
new argument construct to include ">", ">=", etc. for range searches. Modes
21 and 24 are faster versions (They do not return accurate chain counts) of
modes 1 and 4, respectively. Mode 10 allows you to simulate the current
DBFIND mode 1 even when the dataset has a B-tree, BTREEMODE1 is ON and the
argument contains a wildcard character.
- The status array reflects information based on dataset, mode and
search type. B-tree searches with modes 1 and 4 for details give superchain
(multiple detail chain) counts and pointers to the first entry in the first
detail chain and to the last entry in the last detail chain. For masters,
only the count of qualified entries is returned for modes 1 and 4 (pointer
information is set to zeroes).
- DBGET modes 5 and 6 can be used for master B-tree searches as well as
for details. Superchains are traversed for details.
- There is one KSAM/iX privileged file for each B-tree. The file-system
size limit for this B-tree file is 4Gb. A Jumbo master (larger than 4Gb)
can have a B-tree, provided the B-tree remains within its 4Gb limit.
- The KSAM/iX B-tree file is named using the POSIX file format with the
"idx" extension. Example: /ACTSALES/GRPSALES/ORDERS03.idx
- Only the full master key value (without pointer information) is
written to the KSAM/iX file.
- Record zero of the root file contains "C4" for the root file version
if at least one B-tree exists for the database. When all B-trees are
dropped, it reverts to the appropriate version"C3," if at least one Jumbo
set exists. Otherwise, its "C2".
- A new bit map is added in the root file for B-trees.
- During ATTACH, the SQL Optimizer is made aware of B-tree indices which
can be found in the SQL table, SYSTEM.INDEX, of the SQL catalog. B-tree
indices are registered only in the DBE to which the database is ATTACHed.
For a master, a B-tree is registered as a UNIQUE index. All of its
corresponding detail search items are registered as having NON-UNIQUE
indices.
- Third-party indices can coexist with B-trees.
Remember that with more indices, there is more overhead for
puts/deletes/updates, as well as increased complexity for the SQL Optimizer
(The INDEX for the query is chosen by the SQL Optimizer and cannot be
overridden by the user.)
The enhancement highlights demonstrate that B-trees can accomodate a
variety of customer needs that exist in a single computing environment.
Furthermore, there are many ways you can start using this enhancement.
How to get started quickly
For sophisticated use of B-trees, especially for range searches for numeric
items, you will need to make application changes. More detailed information
on advance use is beyond the scope of this article. However, if you desire
generic search only and want to get started quickly without making any
application changes, you may employ the following approach.
First, you must identify the masters that need B-trees. Then, you must
create B-trees using one of the following two methods:
For new databases, use the new INDEXED option of DBSCHEMA, with the
following syntax:
Name: setname,
[/indexed]
[(read-class-list)/(write-class-list)]
[,device-class];
For example:
Name: Employeename, manual /indexed
(10,20/30);
For existing databases, use the new ADDINDEX command of DBUTIL.with the
following syntax:
addindex basename [/maintword]
for
where setnamelist := setname[,...] and
setnumlist := setnum[,...]
For example:
>Addindex orders/secret for ALL
>addindex orders/secret for 1,7
>Addindex orders/secret for SalesrepName,Region, District
BTREEMODE1 option: Set the BTREEMODE1 option ON using DBUTIL with
the following syntax:
set dbname[/maintword]
BTREEMODE1=< on | off> [,[wildcard=]c]
where "c" is any printable ASCII character. Notice that "wildcard="
is optional (i.e., you can type the wildcard character by itself).
For example:
set orders/secret BTREEMODE1 = on
set tape/pass BTREEMODE1 = on, @
set cust/boss BTREEMODE1 = on, wildcard = *
Now you are ready to perform a B-tree search. If your database is new, you
will need to add data. After that, you can include the wildcard character
in your DBFIND argument and start observing the results.
Are you hungry for more? The above method is the quickest and simplest way
to benefit from B-trees. More information on advanced use of B-trees will
be made available later via different media.
If you are interested in beta testing the B-trees enhancement, please send
me an e-mail message, copying your HP support person: bharati@cup.hp.com
Copyright 1996, The 3000 NewsWire. All rights reserved.