An example of index storage

The following examples take OracleDatasource as an example to introduce the maintenance method of Spatial Index and the storage of the index according to the index type, so that advanced users can deeply understand the structure of the index in the database.

Q-tree Index

Scope of application: It is suitable for high-concurrency editing of small data volume.

Maintenance method: There is no corresponding index table. If this index is created, only the SmKey value of the Dataset Properties table will be modified.

Index storage example:

R-tree index

Scope of application: is more suitable for static data, such as data used as a base map and data that is not frequently edited (except for the editing of attribute data). It is recommended to establish an R-tree index.

Maintenance method:

  • Corresponding index table name: sm _ idx _ Dataset table name, used to store the data of R-tree Index.
  • When the index is created and the DatasetGeometry is not modified, the SmKey of the Dataset Properties table is -2.
  • SmIndexLevel = 0 in registry smregister.
  • If a record is added or modified, the SmKey for this record may be greater than -2 (as determined by the R-tree Index algorithm).
  • If there is a record of SmKey greater than -2, then SmIndexLevel = 5 in the registry smregister.

Index storage example:

Mapsheet Index

Scope of application:

  • Field Index: The spatial objects are classified according to a certain Property Field of the Dataset, and the classified spatial objects are managed through the index, so as to improve the query and retrieval speed.
  • Tile Index: The spatial objects are classified according to a given range (the length and width of the map sheet), and the classified spatial objects are managed through the index, so as to improve the query and retrieval speed.

Maintenance method:

  • Corresponding index table name: Lib _ Dataset table name.
  • The SmLibTileID value in the Dataset Properties table corresponds to the SmID in the index table.
  • The SMLIBTILE NAME field records the row and column number of the data (the (0,0) value of the row and column number is Calcualting from the lower left corner of the Dataset Bounds).
  • The SmLibTileID Field in the Dataset table and the SMID Field in the Index table are in a one-to-many relationship.
  • The process of data query: Step 1: Obtain the range of the current Map. Step 2: Judge which map sheets need to be displayed in the current view according to the range and the size of each map sheet when the Mapsheet Index is divided; Step 3, find the SMID value corresponding to these map frames in the corresponding index table (Lib _ Dataset table name); Step 4, find the object to be displayed through the association between this SMID value and the SmLibTileID Field in the Dataset table. Through the above four steps, you can quickly locate the object you want to display.
  • For a newly added object, if the object is outside the original Dataset Bounds, the object will be added to SMID = 1 in the index table.

Index storage example:

Dynamic Index

Scope of application: combines the advantages of R-tree Index and Q-tree Index, provides very good concurrent editing support, and has very good universality.

Maintenance method:

  • Corresponding index table name: SM _ GDX _ DatasetID.
  • The SmDynamicIndex table records the Dynamic Index information of each Dataset.

Index storage example:

Remark

After the data is added or deleted, the index will be automatically maintained. However, in order not to affect the display efficiency, the maintenance will not rebuild the index. Therefore, after a large number of additions and deletions, it is recommended to manually rebuild the index to update and maintain the index and ensure the display and query efficiency of the data.