Database index
The optional database indexes are defined using the GN4-specific extension element ‘index’ placed in the ‘annotation/appInfo’ sub-element of the complexType element.
This example defines an object type ‘test’ with three string attributes ‘location’, ‘city’ and ‘caption’ with a normal database index on the ‘location’ and ‘city’ attributes:
<xs:element name="test">
<xs:complexType gs:key="location">
<xs:annotation>
<xs:appinfo>
<gs:index attrs="location city"/>
</xs:appinfo>
</xs:annotation>
<xs:complexContent>
<xs:extension base="object">
<xs:attribute
name="location"
type="xs:string"/>
<xs:attribute
name="city"
type="xs:string"/>
<xs:attribute name="caption">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="20000"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
The database index will speed up searches of ‘test’ objects by location and city (and it will slow down modification of those attributes).
When specifying indexes in the schema it is now possible to use also the 'built-in' columns that do not correspond to an attribute. In such cases use directly the name of the column instead than the name of the attribute. The valid column names are gn_ParentId (within list and multi-reference attributes), gn_ChildId (within multi-reference attributes), gn_Order (within ordered list and multi-reference attributes) and s_id (within the main object declarations). For example to create an index on pageRef and the parent object id for the list attribute linkObject.pageLayers use: <xs:complexType name="linkObject"> <xs:complexContent> <xs:extension base="folderObject"> <xs:sequence> . . . <xs:element name="pageLayers" minOccurs="0" gs:compute="true"> <xs:complexType> <xs:sequence> <xs:element name="item" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:annotation> <xs:appinfo> . . . <gs:index attrs="pageRef gn_ParentId"/> </xs:appinfo> </xs:annotation> <xs:sequence> . . . <xs:element name="pageRef" type="reference" minOccurs="0" gs:refer="page"> . . . . Note that this specific index has already been added to the standard schemas. |
The following can be used in database index: •Automatically computed attributes •'built-in columns' (since the version 1.6) The following cannot be used in database index: •The special id attribute (in both normal or full-text index) (except s_id in version 1.6 and newer) •Data content, access or multiple references attributes •String attributes with a high maximum length that are stored in the database as unlimited length text •Inherited attributes Applying these rules in the previous example, the ‘test’ object type inherits the ‘name’ attribute from ‘object’ – but ‘name’ cannot be used in the index. The index for ‘name’ must be placed in the definition of the ‘object’ type. |