Skip to main content

Index Definitions

Describes the structure of an index definition.


An index is a structure maintained by a persistent class that is intended to be used to optimize queries and other functions. These indices are automatically maintained whenever INSERT, UPDATE, or DELETE SQL-based operations are carried out against the database; likewise for object-based actions. The SQL Query Processor makes use of available indices when preparing and executing SQL queries.

You can add index definitions to persistent classes. They are not meaningful in other kinds of classes.


An index definition has the following structure:

/// description Index name On property_expression_list [ keyword_list ];


  • description (optional) is intended for display in the Class Reference. The description is blank by default. See “Creating Class Documentation” in Using Caché Objects.

  • name (required) is the name of the index. The name must follow property naming conventions and be unique within this class or table.

    This name is used for database administrative purposes (reporting, index building, dropping indices, and so on). For information on property naming conventions, see “Class Members” in the Caché Programming Orientation Guide. For information on the relationship between an index name in a class definition and the corresponding SQL index name, see “CREATE INDEX” in the Caché SQL Reference.

  • property_expression_list (required) specifies the property or properties on which the index is based and may also include a collation specification for each property. This option is either a single property expression or a comma-separated list of property expressions, enclosed in parentheses.

    A given property expression consists of:

    • The name of the property to be indexed.

    • An optional (ELEMENTS) or (KEYS) expression, which provides a means of indexing on collection subvalues.

    • An optional collation expression.

    For more details, see “Defining and Building Indices” in the Caché SQL Optimization Guide.

  • keyword_list (optional) is a comma-separated list of keywords that further define the index.

    See the section “Index Keywords.”

    If this list is omitted, also omit the square brackets.

For example, the following class definition defines two properties and an index based on each of them:

Class MyApp.Student Extends %Persistent 

Property Name As %String;

Property GPA As %Float;

Index NameIDX On Name;


See Also

FeedbackOpens in a new tab