Home Explore Blog CI



postgresql

25th chunk of `doc/src/sgml/ref/pgbench.sgml`
f587315de8170a111f841c989079259d4eeeec180b2cca990000000100000fa7
 <parameter>value</parameter> <optional>, <parameter>seed</parameter> </optional> )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Computes <ulink url="https://en.wikipedia.org/wiki/MurmurHash">MurmurHash2 hash</ulink>.
       </para>
       <para>
        <literal>hash_murmur2(10, 5432)</literal>
        <returnvalue>-5817877081768721676</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>int</function> ( <replaceable>number</replaceable> )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Casts to integer.
       </para>
       <para>
        <literal>int(5.4 + 3.8)</literal>
        <returnvalue>9</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>least</function> ( <replaceable>number</replaceable> <optional>, <literal>...</literal> </optional> )
        <returnvalue></returnvalue> <type>double</type> if any argument is double, else <type>integer</type>
       </para>
       <para>
        Selects the smallest value among the arguments.
       </para>
       <para>
        <literal>least(5, 4, 3, 2.1)</literal>
        <returnvalue>2.1</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>ln</function> ( <replaceable>number</replaceable> )
        <returnvalue>double</returnvalue>
       </para>
       <para>
        Natural logarithm
       </para>
       <para>
        <literal>ln(2.718281828459045)</literal>
        <returnvalue>1.0</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
<function>mod</function> ( <replaceable>integer</replaceable>, <replaceable>integer</replaceable> )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Modulo (remainder)
       </para>
       <para>
        <literal>mod(54, 32)</literal>
        <returnvalue>22</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>permute</function> ( <parameter>i</parameter>, <parameter>size</parameter> [, <parameter>seed</parameter> ] )
        <returnvalue>integer</returnvalue>
       </para>
       <para>
        Permuted value of <parameter>i</parameter>, in the range
        <literal>[0, size)</literal>.  This is the new position of
        <parameter>i</parameter> (modulo <parameter>size</parameter>) in a
        pseudorandom permutation of the integers <literal>0...size-1</literal>,
        parameterized by <parameter>seed</parameter>, see below.
       </para>
       <para>
        <literal>permute(0, 4)</literal>
        <returnvalue>an integer between 0 and 3</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>pi</function> ()
        <returnvalue>double</returnvalue>
       </para>
       <para>
        Approximate value of <phrase role="symbol_font">&pi;</phrase>
       </para>
       <para>
        <literal>pi()</literal>
        <returnvalue>3.14159265358979323846</returnvalue>
       </para></entry>
      </row>

      <row>
       <entry role="func_table_entry"><para role="func_signature">
        <function>pow</function> ( <parameter>x</parameter>, <parameter>y</parameter> )
        <returnvalue>double</returnvalue>
       </para>
       <para role="func_signature">
        <function>power</function> ( <parameter>x</parameter>, <parameter>y</parameter> )
        <returnvalue>double</returnvalue>
       </para>
       <para>
        <parameter>x</parameter> raised to the power of <parameter>y</parameter>
       </para>
       <para>
        <literal>pow(2.0, 10)</literal>
        <returnvalue>1024.0</returnvalue>

Title: pgbench Built-In Functions (Part 2)
Summary
This section continues describing built-in functions available in pgbench. It includes functions such as `least` (selects smallest value), `ln` (natural logarithm), `mod` (modulo/remainder), `permute` (permuted value within range), `pi` (approximate value of pi), and `pow`/`power` (x raised to the power of y) with examples.