Access Method Support Routines
14.4. Access Method Support Routines
Strategies aren't usually enough information for the system to figure out how to use an index. In practice, the access methods require additional support routines in order to work. For example, the B-tree access method must be able to compare two keys and determine whether one is greater than, equal to, or less than the other. Similarly, the R-tree access method must be able to compute intersections, unions, and sizes of rectangles. These operations do not correspond to operators used in qualifications in SQL queries; they are administrative routines used by the access methods, internally.
Just as with operators, the operator class identifies which specific functions should play each of these roles for a given data type and semantic interpretation. The index access method specifies the set of functions it needs, and the operator class identifies the correct functions to use by assigning "support function numbers" to them.
B-trees require a single support function, as shown in Table 14-4.
Table 14-4. B-tree Support Functions
Function | Support Number |
---|---|
Compare two keys and return an integer less than zero, zero, or greater than zero, indicating whether the first key is less than, equal to, or greater than the second. | 1 |
Hash indexes likewise require one support function, as shown in Table 14-5.
R-tree indexes require three support functions, as shown in Table 14-6.
GiST indexes require seven support functions, as shown in Table 14-7.