Defining indexes

Build 1501 on 14/Nov/2017  This topic last edited on: 21/Mar/2016, at 18:36

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).

Click to toggle expandChanges in version 1.6
Click to toggle expandRules for defining indexes