pgsql: Avoid copying index tuples when building an index.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid copying index tuples when building an index.
Date: 2014-07-01 14:38:06
Message-ID: E1X1zCA-0007tT-1h@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid copying index tuples when building an index.

The previous code, perhaps out of concern for avoid memory leaks, formed
the tuple in one memory context and then copied it to another memory
context. However, this doesn't appear to be necessary, since
index_form_tuple and the functions it calls take precautions against
leaking memory. In my testing, building the tuple directly inside the
sort context shaves several percent off the index build time.
Rearrange things so we do that.

Patch by me. Review by Amit Kapila, Tom Lane, Andres Freund.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9f03ca915196dfc871804a1f8aad26207f601fd6

Modified Files
--------------
src/backend/access/common/indextuple.c | 3 +++
src/backend/access/hash/hash.c | 32 +++++++++++++-------------------
src/backend/access/hash/hashsort.c | 5 +++--
src/backend/access/nbtree/nbtree.c | 11 ++---------
src/backend/access/nbtree/nbtsort.c | 5 +++--
src/backend/utils/sort/tuplesort.c | 23 +++++++++++++----------
src/include/access/hash.h | 3 ++-
src/include/access/nbtree.h | 3 ++-
src/include/utils/tuplesort.h | 4 +++-
9 files changed, 44 insertions(+), 45 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2014-07-01 15:23:30 pgsql: Fix inadequately-sized output buffer in contrib/unaccent.
Previous Message Tom Lane 2014-07-01 02:03:46 pgsql: Issue a WARNING about invalid rule file format in contrib/unacce