Home Explore Blog CI



postgresql

12th chunk of `doc/src/sgml/brin.sgml`
e74415fa8d41ea32a6a8363d70f7f11cfac61785dbac1e520000000100000fa0
 <row><entry><literal>&gt; (varbit,varbit)</literal></entry></row>
    <row><entry><literal>&lt;= (varbit,varbit)</literal></entry></row>
    <row><entry><literal>&gt;= (varbit,varbit)</literal></entry></row>
   </tbody>
  </tgroup>
 </table>

  <sect3 id="brin-builtin-opclasses--parameters">
   <title>Operator Class Parameters</title>

   <para>
    Some of the built-in operator classes allow specifying parameters affecting
    behavior of the operator class.  Each operator class has its own set of
    allowed parameters.  Only the <literal>bloom</literal> and <literal>minmax-multi</literal>
    operator classes allow specifying parameters:
   </para>

   <para>
    bloom operator classes accept these parameters:
   </para>

   <variablelist>
   <varlistentry>
    <term><literal>n_distinct_per_range</literal></term>
    <listitem>
    <para>
     Defines the estimated number of distinct non-null values in the block
     range, used by <acronym>BRIN</acronym> bloom indexes for sizing of the
     Bloom filter. It behaves similarly to <literal>n_distinct</literal> option
     for <xref linkend="sql-altertable"/>. When set to a positive value,
     each block range is assumed to contain this number of distinct non-null
     values. When set to a negative value, which must be greater than or
     equal to -1, the number of distinct non-null values is assumed to grow linearly with
     the maximum possible number of tuples in the block range (about 290
     rows per block). The default value is <literal>-0.1</literal>, and
     the minimum number of distinct non-null values is <literal>16</literal>.
    </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>false_positive_rate</literal></term>
    <listitem>
    <para>
     Defines the desired false positive rate used by <acronym>BRIN</acronym>
     bloom indexes for sizing of the Bloom filter. The values must be
     between 0.0001 and 0.25. The default value is 0.01, which is 1% false
     positive rate.
    </para>
    </listitem>
   </varlistentry>

   </variablelist>

   <para>
    minmax-multi operator classes accept these parameters:
   </para>

   <variablelist>
   <varlistentry>
    <term><literal>values_per_range</literal></term>
    <listitem>
    <para>
     Defines the maximum number of values stored by <acronym>BRIN</acronym>
     minmax indexes to summarize a block range. Each value may represent
     either a point, or a boundary of an interval. Values must be between
     8 and 256, and the default value is 32.
    </para>
    </listitem>
   </varlistentry>

   </variablelist>
  </sect3>

</sect2>

<sect2 id="brin-extensibility">
 <title>Extensibility</title>

 <para>
  The <acronym>BRIN</acronym> interface has a high level of abstraction,
  requiring the access method implementer only to implement the semantics
  of the data type being accessed.  The <acronym>BRIN</acronym> layer
  itself takes care of concurrency, logging and searching the index structure.
 </para>

 <para>
  All it takes to get a <acronym>BRIN</acronym> access method working is to
  implement a few user-defined methods, which define the behavior of
  summary values stored in the index and the way they interact with
  scan keys.
  In short, <acronym>BRIN</acronym> combines
  extensibility with generality, code reuse, and a clean interface.
 </para>

 <para>
  There are four methods that an operator class for <acronym>BRIN</acronym>
  must provide:

  <variablelist>
   <varlistentry>
    <term><function>BrinOpcInfo *opcInfo(Oid type_oid)</function></term>
    <listitem>
     <para>
      Returns internal information about the indexed columns' summary data.
      The return value must point to a palloc'd <structname>BrinOpcInfo</structname>,
      which has this definition:
<programlisting>
typedef struct BrinOpcInfo
{
    /* Number of columns stored in an index column of this opclass */
    uint16      oi_nstored;

    /* Opaque pointer for the opclass' private use */
   

Title: BRIN Operator Class Parameters and Extensibility
Summary
This section describes the parameters allowed for BRIN bloom and minmax-multi operator classes, including n_distinct_per_range, false_positive_rate, and values_per_range, which control the behavior of the index. It then discusses the extensibility of BRIN, highlighting its high level of abstraction and the simplicity of implementing a new access method, which requires defining just a few user-defined methods that specify the behavior of summary values stored in the index.