pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: james+postgres@carbocation.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14654: With high statistics targets on ts_vector, unexpectedly high memory use & OOM are triggered
Date: Wed, 12 Jul 2017 22:09:23 +0300
Message-ID: <8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi> (raw)
In-Reply-To: <4427.1499873459@sss.pgh.pa.us>
References: <20170514200602.1451.46797@wrigleys.postgresql.org>
	<dc65ba89-46d1-07f2-3f94-51ba00446931@iki.fi>
	<4427.1499873459@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 07/12/2017 06:30 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> Yes, I can see that happening here too. The problem seems to be that the
>> analyze-function detoasts every row in the sample. Tsvectors can be very
>> large, so it adds up.
>
>> That's pretty easy to fix, the analyze function needs to free the
>> detoasted copies as it goes. But in order to do that, it needs to make
>> copies of all the lexemes stored in the hash table, instead of pointing
>> directly to the detoasted copies.
>
>> Patch attached. I think this counts as a bug, and we should backport this.
>
> +1.  I didn't test the patch, but it looks sane to the eyeball.

Ok, committed.

In some quick testing on my laptop, and the extra palloc+pfree adds 
about 10% of overhead, in the worst case scenario that every tsvector in 
the sample consists of totally unique lexemes. That's a bit unfortunate, 
but it's a lot better than consuming gigabytes of memory.

- Heikki



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



view thread (4+ messages)

Message-ID: <8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi>
Permalink:  ../8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi/
Also on:    postgresql.org/message-id/8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi

 · 

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-bugs@postgresql.org
  Cc: hlinnaka@iki.fi, tgl@sss.pgh.pa.us, james+postgres@carbocation.com
  Subject: Re: BUG #14654: With high statistics targets on ts_vector, unexpectedly high memory use & OOM are triggered
  In-Reply-To: <8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi>
  References: <20170514200602.1451.46797@wrigleys.postgresql.org> <dc65ba89-46d1-07f2-3f94-51ba00446931@iki.fi> <4427.1499873459@sss.pgh.pa.us> <8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi>

* 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