linkend="sql-createtype"/> for more information about creating
range types.
</para>
</sect2>
<sect2 id="rangetypes-indexing">
<title>Indexing</title>
<indexterm>
<primary>range type</primary>
<secondary>indexes on</secondary>
</indexterm>
<para>
GiST and SP-GiST indexes can be created for table columns of range types.
GiST indexes can be also created for table columns of multirange types.
For instance, to create a GiST index:
<programlisting>
CREATE INDEX reservation_idx ON reservation USING GIST (during);
</programlisting>
A GiST or SP-GiST index on ranges can accelerate queries involving these
range operators:
<literal>=</literal>,
<literal>&&</literal>,
<literal><@</literal>,
<literal>@></literal>,
<literal><<</literal>,
<literal>>></literal>,
<literal>-|-</literal>,
<literal>&<</literal>, and
<literal>&></literal>.
A GiST index on multiranges can accelerate queries involving the same
set of multirange operators.
A GiST index on ranges and GiST index on multiranges can also accelerate
queries involving these cross-type range to multirange and multirange to
range operators correspondingly:
<literal>&&</literal>,
<literal><@</literal>,
<literal>@></literal>,
<literal><<</literal>,
<literal>>></literal>,
<literal>-|-</literal>,
<literal>&<</literal>, and
<literal>&></literal>.
See <xref linkend="range-operators-table"/> for more information.
</para>
<para>
In addition, B-tree and hash indexes can be created for table columns of
range types. For these index types, basically the only useful range
operation is equality. There is a B-tree sort ordering defined for range
values, with corresponding <literal><</literal> and <literal>></literal> operators,
but the ordering is rather arbitrary and not usually useful in the real
world. Range types' B-tree and hash support is primarily meant to
allow sorting and hashing internally in queries, rather than creation of
actual indexes.
</para>
</sect2>
<sect2 id="rangetypes-constraint">
<title>Constraints on Ranges</title>
<indexterm>
<primary>range type</primary>
<secondary>exclude</secondary>
</indexterm>
<para>