pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@postgresql.org
Subject: pgsql: Reduce memory usage of tsvector type analyze function.
Date: Wed, 12 Jul 2017 19:06:59 +0000
Message-ID: <E1dVMyR-0000j0-Ec@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Reduce memory usage of tsvector type analyze function.

compute_tsvector_stats() detoasted and kept in memory every tsvector value
in the sample, but that can be a lot of memory. The original bug report
described a case using over 10 gigabytes, with statistics target of 10000
(the maximum).

To fix, allocate a separate copy of just the lexemes that we keep around,
and free the detoasted tsvector values as we go. This adds some palloc/pfree
overhead, when you have a lot of distinct lexemes in the sample, but it's
better than running out of memory.

Fixes bug #14654 reported by James C. Reviewed by Tom Lane. Backport to
all supported versions.

Discussion: https://www.postgresql.org/message-id/20170514200602.1451.46797@wrigleys.postgresql.org

Branch
------
REL9_2_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/40ba61b447829a328963f5a868b291ecb24762d6

Modified Files
--------------
src/backend/tsearch/ts_typanalyze.c | 21 +++++++++++++++++----
1 file changed, 17 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


view thread (6+ messages)  latest in thread

Message-ID: <E1dVMyR-0000j0-Ec@gemulon.postgresql.org>
Permalink:  ../E1dVMyR-0000j0-Ec@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1dVMyR-0000j0-Ec@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: heikki.linnakangas@iki.fi
  Subject: Re: pgsql: Reduce memory usage of tsvector type analyze function.
  In-Reply-To: <E1dVMyR-0000j0-Ec@gemulon.postgresql.org>
  References: <E1dVMyR-0000j0-Ec@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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