pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Use abbreviated keys for faster sorting of text datums.
2+ messages / 1 participants
[nested] [flat]

* pgsql: Use abbreviated keys for faster sorting of text datums.
@ 2015-01-19 20:28 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Robert Haas @ 2015-01-19 20:28 UTC (permalink / raw)
  To: pgsql-committers

Use abbreviated keys for faster sorting of text datums.

This commit extends the SortSupport infrastructure to allow operator
classes the option to provide abbreviated representations of Datums;
in the case of text, we abbreviate by taking the first few characters
of the strxfrm() blob.  If the abbreviated comparison is insufficent
to resolve the comparison, we fall back on the normal comparator.
This can be much faster than the old way of doing sorting if the
first few bytes of the string are usually sufficient to resolve the
comparison.

There is the potential for a performance regression if all of the
strings to be sorted are identical for the first 8+ characters and
differ only in later positions; therefore, the SortSupport machinery
now provides an infrastructure to abort the use of abbreviation if
it appears that abbreviation is producing comparatively few distinct
keys.  HyperLogLog, a streaming cardinality estimator, is included in
this commit and used to make that determination for text.

Peter Geoghegan, reviewed by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4ea51cdfe85ceef8afabceb03c446574daa0ac23

Modified Files
--------------
src/backend/access/nbtree/nbtsort.c    |    2 +
src/backend/commands/analyze.c         |    6 +
src/backend/executor/nodeAgg.c         |    4 +
src/backend/executor/nodeMergeAppend.c |    9 +
src/backend/executor/nodeMergejoin.c   |    8 +
src/backend/lib/Makefile               |    2 +-
src/backend/lib/hyperloglog.c          |  228 ++++++++++++++++++
src/backend/utils/adt/orderedsetaggs.c |    8 +-
src/backend/utils/adt/varlena.c        |  330 +++++++++++++++++++++++--
src/backend/utils/sort/tuplesort.c     |  413 ++++++++++++++++++++++++++++----
src/include/lib/hyperloglog.h          |   67 ++++++
src/include/pg_config_manual.h         |   14 +-
src/include/utils/sortsupport.h        |  134 ++++++++++-
13 files changed, 1149 insertions(+), 76 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* pgsql: Use abbreviated keys for faster sorting of numeric datums.
@ 2015-04-02 18:07 Robert Haas <rhaas@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Robert Haas @ 2015-04-02 18:07 UTC (permalink / raw)
  To: pgsql-committers

Use abbreviated keys for faster sorting of numeric datums.

Andrew Gierth, reviewed by Peter Geoghegan, with further tweaks by me.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/abd94bcac4582903765be7be959d1dbc121df0d0

Modified Files
--------------
src/backend/utils/adt/numeric.c  |  458 ++++++++++++++++++++++++++++++++++++++
src/backend/utils/misc/guc.c     |    3 -
src/include/catalog/catversion.h |    2 +-
src/include/catalog/pg_amproc.h  |    1 +
src/include/catalog/pg_proc.h    |    2 +
src/include/utils/builtins.h     |    1 +
src/include/utils/guc.h          |    4 +
7 files changed, 467 insertions(+), 4 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-04-02 18:07 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-01-19 20:28 pgsql: Use abbreviated keys for faster sorting of text datums. Robert Haas <rhaas@postgresql.org>
2015-04-02 18:07 pgsql: Use abbreviated keys for faster sorting of numeric datums. Robert Haas <rhaas@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox