EnterpriseDB provides several index types:
B-tree, R-tree, GiST, and Hash. Each index type uses a different
algorithm that is best suited to different types of queries.
By default, the CREATE INDEX command will create a
B-tree index, which fits the most common situations. B-trees can
handle equality and range queries on data that can be sorted into
some ordering. In
particular, the EnterpriseDB query planner
will consider using a B-tree index whenever an indexed column is
involved in a comparison using one of these operators:
<, <=, =, >=, >
The optimizer can also use a B-tree index for queries involving the
pattern matching operators LIKE and ~
if the pattern is a constant and is anchored to
the beginning of the string - for example, col LIKE 'foo%' or
col ~ '^foo', but not col LIKE '%bar'.
However, if your server does not use the C locale you will need to create the
index with a special operator class to support indexing of pattern-matching queries.
See Section 10.7 below. It is also possible to use B-tree indexes
for ILIKE and ~*, but only if the pattern starts
with non-alphabetic characters, i.e. characters that are not affected by upper/lower
case conversion.
R-tree indexes are suited for queries on spatial data. To create
an R-tree index, use a command of the form
CREATE INDEX name ON table USING RTREE (column);
The EnterpriseDB query planner will
consider using an R-tree index whenever an indexed column is
involved in a comparison using one of these operators:
<<, &<, &>, >>, @, ~=, &&
Hash indexes can only handle simple equality comparisons.
The query planner will consider using a hash index whenever an
indexed column is involved in a comparison using the
= operator. The following command is used to
create a hash index:
CREATE INDEX name ON table USING HASH (column);
Note: Testing has shown EnterpriseDB's hash
indexes to perform no better than B-tree indexes, and the
index size and build time for hash indexes is much worse. For
these reasons, hash index use is presently discouraged.
The B-tree index method is an implementation of Lehman-Yao
high-concurrency B-trees. The R-tree index method implements
standard R-trees using Guttman's quadratic split algorithm. The
hash index method is an implementation of Litwin's linear hashing. We
mention the algorithms used solely to indicate that all of these
index methods are fully dynamic and do not have to be optimized
periodically (as is the case with, for example, static hash methods).