Skip to content

DF_INDEX_TYPE

See Also: Get_Attribute, Set_Attribute

The type of the index.

Level

Index

Supported by

All Drivers

Type

Enumeration list, permanent

Access

Read / Write

Values

  • DF_INDEX_TYPE_ONLINE
  • DF_INDEX_TYPE_BATCH

Remarks

Online indices are updated whenever a record is added, deleted, or has an indexed column changed. Batch indices are updated only when the index is rebuilt. The idea of having batch indices is that, since they are not updated upon a save or delete, the save and delete operations are faster. The index update speed is not such a big issue anymore, so there is not much need for batch indices.

This attribute is part of the basic set of attributes that must be supported by all drivers. However, it does not make any sense in some backends. The DataFlex Pervasive.SQL Driver and the DataFlex SQL Drivers will return DF_INDEX_TYPE_ONLINE for every table accessed. Trying to set the attribute will be ignored.

This attribute can only be set inside a Structure_Start ... Structure_End operation.

Procedure SortBatchIndexes
    Handle hTable
    Integer iLastIndex
    Integer iIndex
    Integer iNumSegments
    Integer iIndexType
    String sTable
    String sSort

    Move 0 To hTable
    Repeat
        Get_Attribute DF_FILE_NEXT_USED Of hTable To hTable
        If (hTable > 0) Begin
            Get_Attribute DF_FILE_ROOT_NAME Of hTable To sTable
            If (Uppercase(sTable) <> "FLEXERRS") Begin
                Move "" To sSort
                Open hTable Mode DF_EXCLUSIVE
                Get_Attribute DF_FILE_LAST_INDEX_NUMBER Of hTable To iLastIndex
                For iIndex From 1 To iLastIndex
                    Get_Attribute DF_INDEX_NUMBER_SEGMENTS Of hTable iIndex To iNumSegments
                    If (iNumSegments > 0) Begin
                        Get_Attribute DF_INDEX_TYPE Of hTable iIndex To iIndexType
                        If (iIndexType = DF_INDEX_TYPE_BATCH) ;
                            Move (sSort * String(iIndex)) To sSort
                    End
                Loop
                If (sSort <> "") ;
                    Sort hTable sSort
                Close hTable
            End
        End
    Until (hTable = 0)
End_Procedure // SortBatchIndexes

The sample procedure above opens all tables in the file list and re-indexes all batch indexes for every table.