of the
second?
[a, b] &> [c, d] is true if a >= c.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>seg</type> <literal>=</literal> <type>seg</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Are the two <type>seg</type>s equal?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>seg</type> <literal>&&</literal> <type>seg</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Do the two <type>seg</type>s overlap?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>seg</type> <literal>@></literal> <type>seg</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Does the first <type>seg</type> contain the second?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>seg</type> <literal><@</literal> <type>seg</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Is the first <type>seg</type> contained in the second?
</para></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
In addition to the above operators, the usual comparison
operators shown in <xref linkend="functions-comparison-op-table"/> are
available for type <type>seg</type>. These operators
first compare (a) to (c),
and if these are equal, compare (b) to (d). That results in
reasonably good sorting in most cases, which is useful if
you want to use ORDER BY with this type.
</para>
</sect2>
<sect2 id="seg-notes">
<title>Notes</title>
<para>
For examples of usage, see the regression test <filename>sql/seg.sql</filename>.
</para>
<para>
The mechanism that converts <literal>(+-)</literal> to regular ranges
isn't completely accurate in determining the number of significant digits
for the boundaries. For example, it adds an extra digit to the lower
boundary if the resulting interval includes a power of ten:
<screen>
postgres=> select '10(+-)1'::seg as seg;
seg
---------
9.0 .. 11 -- should be: 9 .. 11
</screen>
</para>
<para>
The performance of an R-tree index can largely depend on the initial
order of input values. It may be very helpful to sort the input table
on the <type>seg</type> column; see the script <filename>sort-segments.pl</filename>
for an example.
</para>
</sect2>
<sect2 id="seg-credits">
<title>Credits</title>
<para>
Original author: Gene Selkov, Jr. <email>selkovjr@mcs.anl.gov</email>,
Mathematics and Computer Science Division, Argonne National Laboratory.
</para>
<para>
My thanks are primarily to Prof. Joe Hellerstein
(<ulink url="https://dsf.berkeley.edu/jmh/"></ulink>) for elucidating the
gist of the GiST (<ulink url="http://gist.cs.berkeley.edu/"></ulink>). I am
also grateful to all Postgres developers, present and past, for enabling
myself to create my own world and live undisturbed in it. And I would like
to acknowledge my gratitude to Argonne Lab and to the U.S. Department of
Energy for the years of faithful support of my database research.
</para>
</sect2>
</sect1>