Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVN1a-0001hJ-61 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Jul 2017 19:10:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dVN1Z-00041k-P9 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Jul 2017 19:10:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dVN0t-0002ln-1X for pgsql-bugs@postgresql.org; Wed, 12 Jul 2017 19:09:31 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dVN0q-0004yR-6e for pgsql-bugs@postgresql.org; Wed, 12 Jul 2017 19:09:29 +0000 Received: by mail-lf0-x244.google.com with SMTP id f28so3932964lfi.3 for ; Wed, 12 Jul 2017 12:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=oUuDPDzYFfZifFU051u4FnOl1shswVVqxfauFgVZXIc=; b=eepFFvly+wT4MBHGYMnspvs7Tghgzq/zyo9cTwSSfWkXUljvjTSxrOS0aOWrZOoJFx X4OhxS5Ogxnp90dpkM82W72WZv7EWsCeG8BN5tbm0z0jOR8eNvgWfmwK9+8O8ifDBRmk kmO+sHoDC60AaShXSnj+Pbr+/Q80oVugukMvzFlSTdrgi6nrF+a06gQz2m1Dmq7PQQYS nbfI22nXxts7oGELJtDFhejhg+eo5mBtANRWrqiWmAPxNmo9LYDqQv7t95UCHYeSHnN4 9m4rfaJeLtmdGMIwV6UrZtIfiPqPL2PtKHW+ev1tn40A1gT0IoR16orBm/HWWRWqX5lm IRZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=oUuDPDzYFfZifFU051u4FnOl1shswVVqxfauFgVZXIc=; b=JiyZ7DvWqVq+x/Jwt6j9UsO929lQ8BYMGyJ/wzH65Xu/DSORd+C5IMTN928RkPkp0J x/q/rll7hvVGxF7Kee2R/br5cfJzb8EXsz3XHN1IwlI7v3OJ+NH1WkkujoOcRjO0Ousu shyQMXIbv+WZi0eFMRxydJa0uY88MPnGqMcJYWeYxgEQkiPlcsIAZqR2CR48MwgtAUp7 5fY5Mt24UNUvchoRZ/gA5+RvYlGLzOP0zPOmR7gYapHUDEvWjaCK1muOqr/oKNIDrJwV zGnTCQvNOSGahfatNLGhNZ0XMc51G/H8Sak0Rz8DKQa5BNRbpX86cKkemjk6ni/37AIH uPkw== X-Gm-Message-State: AIVw1126A1ZqRQ6AWaUwkJKSCcpSZLBDMeFnggboeo0qp9LjguCPWecp 4X4bn1s1+douO3Sj X-Received: by 10.46.77.193 with SMTP id c62mr26979ljd.72.1499886566258; Wed, 12 Jul 2017 12:09:26 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibng32-54fb4e-103.dhcp.inet.fi. [84.251.78.103]) by smtp.gmail.com with ESMTPSA id x90sm729368lfb.10.2017.07.12.12.09.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 12:09:25 -0700 (PDT) Subject: Re: BUG #14654: With high statistics targets on ts_vector, unexpectedly high memory use & OOM are triggered To: Tom Lane References: <20170514200602.1451.46797@wrigleys.postgresql.org> <4427.1499873459@sss.pgh.pa.us> Cc: james+postgres@carbocation.com, pgsql-bugs@postgresql.org From: Heikki Linnakangas Message-ID: <8cd9ffd4-b32b-2eeb-9451-e1a104e93be2@iki.fi> Date: Wed, 12 Jul 2017 22:09:23 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <4427.1499873459@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 07/12/2017 06:30 PM, Tom Lane wrote: > Heikki Linnakangas 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