Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
a596db33
Commit
a596db33
authored
Mar 24, 2016
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve documentation for combine functions.
David Rowley
parent
59a02815
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
11 deletions
+48
-11
doc/src/sgml/catalogs.sgml
doc/src/sgml/catalogs.sgml
+6
-0
doc/src/sgml/ref/create_aggregate.sgml
doc/src/sgml/ref/create_aggregate.sgml
+42
-11
No files found.
doc/src/sgml/catalogs.sgml
View file @
a596db33
...
@@ -406,6 +406,12 @@
...
@@ -406,6 +406,12 @@
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>Final function (zero if none)</entry>
<entry>Final function (zero if none)</entry>
</row>
</row>
<row>
<entry><structfield>aggcombinefn</structfield></entry>
<entry><type>regproc</type></entry>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>Combine function (zero if none)</entry>
</row>
<row>
<row>
<entry><structfield>aggmtransfn</structfield></entry>
<entry><structfield>aggmtransfn</structfield></entry>
<entry><type>regproc</type></entry>
<entry><type>regproc</type></entry>
...
...
doc/src/sgml/ref/create_aggregate.sgml
View file @
a596db33
...
@@ -108,15 +108,12 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
...
@@ -108,15 +108,12 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
functions:
functions:
a state transition function
a state transition function
<replaceable class="PARAMETER">sfunc</replaceable>,
<replaceable class="PARAMETER">sfunc</replaceable>,
an optional final calculation function
and an optional final calculation function
<replaceable class="PARAMETER">ffunc</replaceable>,
<replaceable class="PARAMETER">ffunc</replaceable>.
and an optional combine function
<replaceable class="PARAMETER">combinefunc</replaceable>.
These are used as follows:
These are used as follows:
<programlisting>
<programlisting>
<replaceable class="PARAMETER">sfunc</replaceable>( internal-state, next-data-values ) ---> next-internal-state
<replaceable class="PARAMETER">sfunc</replaceable>( internal-state, next-data-values ) ---> next-internal-state
<replaceable class="PARAMETER">ffunc</replaceable>( internal-state ) ---> aggregate-value
<replaceable class="PARAMETER">ffunc</replaceable>( internal-state ) ---> aggregate-value
<replaceable class="PARAMETER">combinefunc</replaceable>( internal-state, internal-state ) ---> next-internal-state
</programlisting>
</programlisting>
</para>
</para>
...
@@ -133,12 +130,6 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
...
@@ -133,12 +130,6 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
is returned as-is.
is returned as-is.
</para>
</para>
<para>
An aggregate function may also supply a combining function, which allows
the aggregation process to be broken down into multiple steps. This
facilitates query optimization techniques such as parallel query.
</para>
<para>
<para>
An aggregate function can provide an initial condition,
An aggregate function can provide an initial condition,
that is, an initial value for the internal state value.
that is, an initial value for the internal state value.
...
@@ -405,6 +396,46 @@ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
...
@@ -405,6 +396,46 @@ SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
</listitem>
</listitem>
</varlistentry>
</varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">combinefunc</replaceable></term>
<listitem>
<para>
The <replaceable class="PARAMETER">combinefunc</replaceable> may
optionally be specified in order to allow the aggregate function to
support partial aggregation. This is a prerequisite to allow the
aggregate to participate in certain optimizations such as parallel
aggregation.
</para>
<para>
This function can be thought of as an <replaceable class="PARAMETER">
sfunc</replaceable>, where instead of acting upon individual input rows
and adding these to the aggregate state, it adds other aggregate states
to the aggregate state.
</para>
<para>
The <replaceable class="PARAMETER">combinefunc</replaceable> must accept
two arguments of <replaceable class="PARAMETER">state_data_type
</replaceable> and return <replaceable class="PARAMETER">state_data_type
</replaceable>. Optionally this function may be <quote>strict</quote>. In
this case the function will not be called when either of the input states
are null.
</para>
<para>
For aggregate functions with an <literal>INTERNAL</literal>
<replaceable class="PARAMETER">state_data_type</replaceable> the
<replaceable class="PARAMETER">combinefunc</replaceable> must not be
<quote>strict</quote>. In this scenario the
<replaceable class="PARAMETER">combinefunc</replaceable> must take charge
and ensure that the null states are handled correctly and that the state
being returned is a pointer to memory which belongs in the aggregate
memory context.
</para>
</listitem>
</varlistentry>
<varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">initial_condition</replaceable></term>
<term><replaceable class="PARAMETER">initial_condition</replaceable></term>
<listitem>
<listitem>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment