5
Indexing Statements for Object Relational Model
This chapter describes the statements used when working with the spatial object data type. The statements are listed in Table 5-1.
Table 5-1 Spatial Index Creation and Usage Statements
ALTER INDEX
Purpose
This statement alters specific parameters for a spatial index or rebuilds a spatial index.
Syntax
ALTER INDEX [schema.]index PARAMETERS (`index_params [physical_storage_params]' )
Keywords and Parameters
Prerequisites
- You must have EXECUTE privileges on the index type and its implementation type.
- The spatial index to be altered is not marked in-progress.
Usage Notes
This statement is used to change the parameters of an existing index. This is the only way you can add or build multiple indexes on the same column.
Examples
ALTER INDEX qtree PARAMETERS ('add_index=HYBRID_INDEX
sdo_numtiles=8
initial=100M
next=1M
pctincrease=0
btree_initial=5M
btree_next=1M
btree_pctincrease=0');
Related Topics
- ALTER INDEX REBUILD
- ALTER INDEX RENAME TO
ALTER INDEX REBUILD
Purpose
This function rebuilds a spatial index.
Syntax
ALTER INDEX [schema.]index REBUILD
[PARAMETERS (`rebuild_params [physical_storage_params]' ) ]
Keywords and Parameters
Prerequisites
- You must have EXECUTE privileges on the index type and its implementation type.
- The spatial index to be altered is not marked in-progress.
Usage Notes
- sdo_commit_interval: An ALTER INDEX REBUILD `rebuild_params' statement will rebuild the index using supplied parameters. Spatial index creation involves creating and inserting index data, for each row in the underlying table column being spatially indexed, into a table with a prescribed format. The default, or normal, operation is that all rows in the underlying table are processed before the insertion of index data is committed. This requires adequate rollback segment space.
- You may choose to perform commits of index data after every N rows of the underlying table have been processed. This is done by specifying that sdo_commit_interval = N. The potential complication is that if there is an error during index rebuild and periodic commits have taken place, then the spatial index will be in an inconsistent state. The only recovery option is to use DROP INDEX (possibly with the FORCE option) and CREATE INDEX statements after ensuring that the various tablespaces are the required size and any other error conditions have been removed.
- This command does not remember any previous index parameters. All parameters should be specified for the index you want to rebuild.
Examples
The following example builds oldindex with an SDO_LEVEL = 12 and SDO_NUMTILES = NULL.
ALTER INDEX oldindex REBUILD PARAMETERS('sdo_level = 12');
Related Topics
ALTER INDEX RENAME TO
Purpose
This statement alters the name of a spatial index.
Syntax
ALTER INDEX [schema.]index RENAME TO <new_index_name>
Keywords and Parameters
Prerequisites
- You must have EXECUTE privileges on the index type and its implementation type.
- The spatial index to be altered is not marked in-progress.
Usage Notes
None.
Examples
The following example renames the index `oldindex' to `newindex'.
ALTER INDEX oldindex RENAME TO newindex ;
Related Topics
CREATE INDEX
Purpose
This statement creates a spatial index on a column of type MDSYS.SDO_GEOMETRY.
Syntax
CREATE INDEX [schema.]<index_name> ON [schema.]<tableName> (column)
INDEXTYPE IS MDSYS.SPATIAL_INDEX
[PARAMETERS `index_params [physical_storage_params]');
Keywords and Parameters
Prerequisites
- All the current SQL CREATE INDEX prerequisites apply.
- You must have EXECUTE privilege on the index type and its implementation type.
- The SDO_GEOM_METADATA table must contain an entry with the dimensions and coordinate boundary information for the table column to be spatially indexed.
Usage Notes
- Other options available for regular indexes (such as ASC and DESC) are not applicable for spatial indexes.
- The index_params string must contain valid values for either SDO_LEVEL or both SDO_LEVEL and SDO_NUMTILES.
- DEFAULT VALUES:
- sdo_numtiles must be supplied with a value greater than or equal to one to perform hybrid indexing. If this parameter is not supplied, indexing with fixed-size tiles is performed.
- sdo_commit_interval does not allow spatial data to be committed at intervals. Insertion of spatial index data is committed only at the end of the index creation process. That is, it is committed after all rows in the underlying table have been processed.
- sdo_maxlevel equals 32. Modification is not recommended.
- SDO_LEVEL must be greater than zero and less than SDO_MAXLEVEL
- The value passed to SDO_NUMTILES is considered a recommendation. In some cases, this value may be overwritten by the indexing algorithm.
- sdo_commit_interval: Spatial index creation involves creating and inserting index data for each row in the underlying table column being spatially indexed into a table with a prescribed format. The default, or normal, operation is that all rows in the underlying table are processed before the insertion of index data is committed. This requires adequate rollback segment space.
- You may choose to commit index data after every N rows of the underlying table have been processed. This is done by specifying sdo_commit_interval = N. The potential complication is that if there is an error during the rebuilding of the index, and the spatial index data was periodically committed, then the spatial index will be in an inconsistent state. The only recovery option is to use DROP INDEX and CREATE INDEX statements after ensuring that the various tablespaces are the required size, and any other error conditions have been removed.
- Interpretation of SDO_LEVEL and SDO_NUMTILES value combinations are shown in Table 5-2.
- If a TABLESPACE name is provided in the parameters clause, the user (underlying table owner) must have appropriate privileges for that tablespace.
- If the CREATE INDEX statement fails because of an invalid geometry, the ROWID of the failed geometry is returned in an error message along with the reason for the failure.
- If the CREATE INDEX statement fails for any reason, then the DROP INDEX statement must be used to clean up the partially built index and associated metadata. If DROP INDEX does not work, add the FORCE parameter and try again.
Related Topics
DROP INDEX
Purpose
This statement deletes a spatial index.
Syntax
DROP INDEX [schema.]index [FORCE]
Keywords and Parameters
Prerequisites
You must have EXECUTE privileges on the index type and its implementation type.
Usage Notes
Use DROP INDEX indexname FORCE to clean up after a failure in the CREATE INDEX statement.
Examples
- DROP INDEX oldindex
- DROP INDEX oldindex FORCE
Related Topics