About operator classes

Although an R-tree index might exist on a table column, it might not always be possible for the query optimizer to use it when you execute a query, even if the WHERE clause of the query specifies the indexed column.

For example, a query might search for polygons whose area is greater than a specified number. An R-tree index will not likely be of use in this type of query because the access method uses the bounding box of the polygons, and not the area, to create the index. However, a query that searches for polygons that overlap a specified polygon will likely use the R-tree index.

An operator class helps the query optimizer determine whether a secondary access method can be used in a query. It also defines how to access and modify the index if it is used in a query. An operator class specifies a group of functions that work with a new data type and an access method. It links each function to the role it will play in the access method operations.

An operator class defines a way to organize the functions that are implemented in a DataBlade® module and defines how to make them known to the query optimizer and the access method. It identifies the functions that fill particular roles that fall into the following two categories:
Strategy functions
Strategy functions include all the functions whose evaluation can be assisted by an R-tree index. If a strategy function is specified in the WHERE clause of a query, the R-tree index can be used to evaluate the query. Strategy functions are used both directly by end users in the WHERE clause of SQL queries and internally by the R-tree access method to search the index.

An example of a strategy function is the Overlap function, which determines whether two bounding boxes have any points in common.

Support functions
The access method uses the support functions of a secondary access method to build, update, and maintain the index. These functions are not called directly by end users.

An example of a support function is the Size function, which calculates the size of a bounding box.

The R-tree access method, similar to all secondary access methods, has specific operator class requirements for the type and number of strategy and support functions that must be defined. By creating a new operator class, DataBlade developers attach names of actual functions to the placeholders for required functions in the operator class structure, which completes the information the database server needs.

A secondary access method usually has a default operator class associated with it. The default operator class for the R-tree access method is called rtree_ops.

The rtree_ops operator class is generally only used for generic R-tree access method testing and as an example of how to create a new operator class for use with the R-tree access method. It is almost never used directly to create an R-tree index. The rtree_ops operator class has a fixed set of four strategy functions, and it cannot be extended. For this reason, and others described in Develop DataBlade modules that use the R-tree secondary access method, DataBlade developers should always create a new operator class to use the R-tree access method to index the new data types or to extend the types of queries that use the access method.

Develop DataBlade modules that use the R-tree secondary access method describes in detail how to create an operator class and how to set up the necessary strategy and support functions.