1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00
Files
postgres/doc/src/sgml
Tom Lane 7151e72d7f Improve speed of aggregates that use array_append as transition function.
In the previous coding, if an aggregate's transition function returned an
expanded array, nodeAgg.c and nodeWindowAgg.c would always copy it and thus
force it into the flat representation.  This led to ping-ponging between
flat and expanded formats, which costs a lot.  For an aggregate using
array_append as transition function, I measured about a 15X slowdown
compared to the pre-9.5 code, when working on simple int[] arrays.
Of course, the old code was already O(N^2) in this usage due to copying
flat arrays all the time, but it wasn't quite this inefficient.

To fix, teach nodeAgg.c and nodeWindowAgg.c to allow expanded transition
values without copying, so long as the transition function takes care to
return the transition value already properly parented under the aggcontext.
That puts a bit of extra responsibility on the transition function, but
doing it this way allows us to not need any extra logic in the fast path
of advance_transition_function (ie, with a pass-by-value transition value,
or with a modified-in-place pass-by-reference value).  We already know
that that's a hot spot so I'm loath to add any cycles at all there.  Also,
while only array_append currently knows how to follow this convention,
this solution allows other transition functions to opt-in without needing
to have a whitelist in the core aggregation code.

(The reason we would need a whitelist is that currently, if you pass a
R/W expanded-object pointer to an arbitrary function, it's allowed to do
anything with it including deleting it; that breaks the core agg code's
assumption that it should free discarded values.  Returning a value under
aggcontext is the transition function's signal that it knows it is an
aggregate transition function and will play nice.  Possibly the API rules
for expanded objects should be refined, but that would not be a
back-patchable change.)

With this fix, an aggregate using array_append is no longer O(N^2), so it's
much faster than pre-9.5 code rather than much slower.  It's still a bit
slower than the bespoke infrastructure for array_agg, but the differential
seems to be only about 10%-20% rather than orders of magnitude.

Discussion: <6315.1477677885@sss.pgh.pa.us>
2016-10-30 12:27:41 -04:00
..
2016-08-10 21:39:59 -04:00
2014-05-06 21:28:58 -04:00
2015-09-10 21:40:06 -04:00
2016-07-14 22:28:41 -04:00
2015-09-10 21:40:06 -04:00
2015-05-28 13:02:09 -04:00
2015-09-26 21:02:24 -04:00
2015-09-10 21:40:06 -04:00
2016-01-18 21:28:10 +09:00
2016-05-04 14:07:12 -04:00
2015-06-11 00:09:32 -04:00
2016-09-26 11:50:35 -04:00
2016-01-22 12:29:22 -05:00
2016-05-13 21:25:46 -04:00
2016-07-14 22:28:41 -04:00
2015-08-14 12:10:35 -04:00
2016-01-02 13:33:39 -05:00
2015-01-06 11:43:47 -05:00
2015-09-10 21:40:06 -04:00
2015-04-12 19:07:46 +02:00
2015-08-31 14:07:41 +02:00
2014-05-06 21:28:58 -04:00
2014-08-30 10:52:36 -05:00
2016-05-03 21:07:00 -04:00
2015-04-26 10:33:14 -04:00
2015-06-11 00:09:32 -04:00
2015-08-08 20:40:53 -04:00
2016-07-14 22:28:41 -04:00
2015-09-05 11:36:18 +03:00
2014-07-16 22:48:11 -04:00
2014-05-06 21:28:58 -04:00
2015-06-03 20:19:47 -04:00
2016-05-01 21:34:41 -04:00
2014-08-30 10:52:36 -05:00
2014-08-30 10:52:36 -05:00

<!-- doc/src/sgml/README.links -->

Linking within SGML documents can be confusing, so here is a summary:


Intra-document Linking
----------------------

<xref>
	use to get chapter/section number from the title of the target
	link, or xreflabel if defined at the target, or refentrytitle if target
        is a refentry;  has no close tag
	http://www.oasis-open.org/docbook/documentation/reference/html/xref.html

<link>
	use to supply text for the link, requires </link>
	http://www.oasis-open.org/docbook/documentation/reference/html/link.html

linkend=
	controls the target of the link/xref, required

endterm=
	for <xref>, allows the text of the link/xref to be taken from a
	different link target title


External Linking
----------------

<ulink>
	like <link>, but uses a URL (not a document target);  requires
	</ulink>; if no text is specified, the URL appears as the link
	text
	http://www.oasis-open.org/docbook/documentation/reference/html/ulink.html

url=
	used by <ulink> to specify the URL, required


Guidelines
----------

o  If you want to supply text, use <link>, else <xref>
o  Do not use text with <ulink> so the URL appears in printed output
o  Specific nouns like GUC variables, SQL commands, and contrib modules
   usually have xreflabels