Make nodeSort.c use Datum sorts for single column sorts
authorDavid Rowley <drowley@postgresql.org>
Thu, 22 Jul 2021 02:03:19 +0000 (14:03 +1200)
committerDavid Rowley <drowley@postgresql.org>
Thu, 22 Jul 2021 02:03:19 +0000 (14:03 +1200)
commit91e9e89dccdfdf4216953d3d8f5515dcdef177fb
treea5e65de17f8beddb4c3edda646183ec31795e201
parent7fa1e1ef741964eeb50f33d7c72622658bb7e5f4
Make nodeSort.c use Datum sorts for single column sorts

Datum sorts can be significantly faster than tuple sorts, especially when
the data type being sorted is a pass-by-value type.  Something in the
region of 50-70% performance improvements appear to be possible.

Just in case there's any confusion; the Datum sort is only used when the
targetlist of the Sort node contains a single column, not when there's a
single column in the sort key and multiple items in the target list.

Author: Ronan Dunklau
Reviewed-by: James Coleman, David Rowley, Ranier Vilela, Hou Zhijie
Tested-by: John Naylor
Discussion: https://postgr.es/m/3177670.itZtoPt7T5@aivenronan
src/backend/executor/nodeSort.c
src/include/nodes/execnodes.h