Index Creation

This section provides the details for creating an index on an RDBMS stub file such as the syntaxes, left and right justification differences and index samples for the Oracle, DB2, and SQL servers.

Creating an index on an RDBMS stub file is similar to creating an index on a j4 file except the command to use is CREATE-EXTINDEX instead of CREATE-INDEX.

$  create-extindex CUSTOMER MNEMONIC

$ is the index generated on MNEMONIC. Like CREATE-VIEW, you can use the -v option for an on screen trace the happenings. Refer Appendix D for more examples.

Create-extindex Syntax and Options

Due to the nature of SQL Server’s indexing of XML, it may seem confusing. However, there are only two syntaxes—one for SQL and the other for Oracle and DB2.

Listing and Deleting Indices

This section provides details of the LIST-EXTINDEX and DELETE-EXTINDEX commands, syntax, and corresponding examples for Oracle, DB2, and SQL servers.

Usage of Indices

In a regular relational table, an index is typically created on a column or expression that is heavily queried and has enough diversity. This index will be used if a query uses the same expression and optimiser on the database (based on statistics) and is considered the most efficient method of retrieving the results.

Example

The following script shows an index is created on a column.

sql> CREATE INDEX ix_MNEMONIC ON CUSTOMER (MNEMONIC);

In this example, MNEMONIC is the expression and is a column. However, if the script is changed as shown below, the expression is now CAST(MNEMONIC AS INT) and index – ix_MNEMONIC – is not used.

sql> SELECT COUNT(RECID) FROM CUSTOMER WHERE CAST(MNEMONIC AS INT) = 1;

For an XML column, in which you require to reference an element, there is no real column for reference, but an expression, which evaluates the value to be indexed.

The following example shows a valid XML expression to be indexed in Oracle assuming x is the table alias.

substr(extractValue(x.xmlrecord,'/row/c18'),1,11)

The following is the corresponding query for the same.

sql> SELECT RECID FROM CUSTOMER x WHERE substr(extractValue(x.xmlrecord,'/row/c18'),1,11)
= '20070101';

However, if an index is created on CONTACT.DATE, which points to attribute 18 of the CUSTOMER record, the following query is used.

sql> CREATE INDEX nix_CUSTOMER_C18 ON CUSTOMER x (NVL(NUMCUST(extractValue(x.xmlrecord,'/row/c18')),0))

The above index would not be used by the previous query. If the query is changed to the following, the expression in the query is now matching the expression in the index and can be used if it satisfies the optimiser.

sql> SELECT RECID FROM CUSTOMER x WHERE NVL(NUMCAST(substr(extractValue(x.xmlrecord,'/row/c18'),1,11)),0)
= 20070101;

From a Temenos Transact perspective, using the default options on CREATE-EXTINDEX for a given dictionary will use an expression that will match when the same dictionary is used in a query, in most cases.

NOTE: By default, right-justified dictionaries will use some form of numeric casting and may not match the indices available depending on the database type and version.

Determination of Index Usage

The easy method to find if an index is used, is to turn on tracing for the driver, copy the SQL command from the log and use RDBMS tools to analyse the query (often referred as an explain). For Oracle and DB2, the database administrator (DBA) must first create the explain tables or procedures.

Let us examine the following query and how it is handled by the RDBMS query engine, which has an index created on ACCOUNT.OFFICER.

$ COUNT CUSTOMER WITH ACCOUNT.OFFICER = 123456

Bookmark Name Actions
Feedback
x