Home Explore Blog CI



postgresql

11th chunk of `doc/src/sgml/gin.sgml`
64d246bb351d913812a61b36015ab29688e22e362c5f0be70000000100000cc4
 otherwise.
    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><xref linkend="guc-gin-fuzzy-search-limit"/></term>
   <listitem>
    <para>
     The primary goal of developing <acronym>GIN</acronym> indexes was
     to create support for highly scalable full-text search in
     <productname>PostgreSQL</productname>, and there are often situations when
     a full-text search returns a very large set of results.  Moreover, this
     often happens when the query contains very frequent words, so that the
     large result set is not even useful.  Since reading many
     tuples from the disk and sorting them could take a lot of time, this is
     unacceptable for production.  (Note that the index search itself is very
     fast.)
    </para>
    <para>
     To facilitate controlled execution of such queries,
     <acronym>GIN</acronym> has a configurable soft upper limit on the
     number of rows returned: the
     <varname>gin_fuzzy_search_limit</varname> configuration parameter.
     It is set to 0 (meaning no limit) by default.
     If a non-zero limit is set, then the returned set is a subset of
     the whole result set, chosen at random.
    </para>
    <para>
     <quote>Soft</quote> means that the actual number of returned results
     could differ somewhat from the specified limit, depending on the query
     and the quality of the system's random number generator.
    </para>
    <para>
     From experience, values in the thousands (e.g., 5000 &mdash; 20000)
     work well.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>

</sect2>

<sect2 id="gin-limit">
 <title>Limitations</title>

 <para>
  <acronym>GIN</acronym> assumes that indexable operators are strict.  This
  means that <function>extractValue</function> will not be called at all on a null
  item value (instead, a placeholder index entry is created automatically),
  and <function>extractQuery</function> will not be called on a null query
  value either (instead, the query is presumed to be unsatisfiable).  Note
  however that null key values contained within a non-null composite item
  or query value are supported.
 </para>
</sect2>

<sect2 id="gin-examples">
 <title>Examples</title>

 <para>
  The core <productname>PostgreSQL</productname> distribution
  includes the <acronym>GIN</acronym> operator classes previously shown in
  <xref linkend="gin-builtin-opclasses-table"/>.
  The following <filename>contrib</filename> modules also contain
  <acronym>GIN</acronym> operator classes:

 <variablelist>
  <varlistentry>
   <term><filename>btree_gin</filename></term>
   <listitem>
    <para>B-tree equivalent functionality for several data types</para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><filename>hstore</filename></term>
   <listitem>
    <para>Module for storing (key, value) pairs</para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><filename>intarray</filename></term>
   <listitem>
    <para>Enhanced support for <type>int[]</type></para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><filename>pg_trgm</filename></term>
   <listitem>
    <para>Text similarity using trigram matching</para>
   </listitem>
  </varlistentry>
 </variablelist>
 </para>
</sect2>

</sect1>

Title: GIN Index Configuration, Limitations, and Examples
Summary
This section discusses the configuration of GIN indexes, including the fuzzy search limit, as well as limitations and examples of using GIN indexes in PostgreSQL, including supported data types and contrib modules such as btree_gin, hstore, intarray, and pg_trgm