Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YuKxX-00043K-1d for pgsql-bugs@arkaria.postgresql.org; Mon, 18 May 2015 13:19:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YuKxW-0007lH-3V for pgsql-bugs@arkaria.postgresql.org; Mon, 18 May 2015 13:19:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YuKxU-0007lA-Vw for pgsql-bugs@postgresql.org; Mon, 18 May 2015 13:19:53 +0000 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YuKxR-0005eW-Ac for pgsql-bugs@postgresql.org; Mon, 18 May 2015 13:19:52 +0000 Received: by pabts4 with SMTP id ts4so152136054pab.3 for ; Mon, 18 May 2015 06:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=wiu3cCZBwYDJj/9QJndjvSW78WtIf5Ho9T6Qr5/MVs4=; b=Zl+PReGJ65NeQXuHsKdBldYvTBJJPM0Spfci22nL217xm85Zgo8BZP9zcfqBQvZohj aX+GT8sWSw0hoMF0EbL+o8xfbMir+LVz/5AkqzTCttXj6BKSRoN9fagrfA6YzSpM4LQS KozqUh435BBSjZ4JFaA8LuJEzZaJJV9YDANuKWFvytxoMwKkpmWxrZ1+G9CoePoJ0ygG TncdgMGT9y7rnhUKEPAtyW7dhSlyIaYRQWMbjVwrH9pJ1zknEpUcHhX51PVCCNH/wbad aX0+k9qVEJ9m1vXpUlYytvReE0ECmfUkwLNO0ExMa4qE/V4reYLlgfQk7j9wNyzGltGJ wuew== X-Received: by 10.68.215.35 with SMTP id of3mr43841885pbc.50.1431955186534; Mon, 18 May 2015 06:19:46 -0700 (PDT) Received: from [192.168.1.99] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by mx.google.com with ESMTPSA id jp10sm10103503pbb.9.2015.05.18.06.19.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 May 2015 06:19:45 -0700 (PDT) Message-ID: <5559E6ED.2010405@iki.fi> Date: Mon, 18 May 2015 16:19:41 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: depesz@depesz.com, pgsql-bugs Subject: Re: GiST index for pgtrgm bloats a lot References: <20150518121250.GA19976@depesz.com> In-Reply-To: <20150518121250.GA19976@depesz.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 05/18/2015 03:12 PM, hubert depesz lubaczewski wrote: > Hi, > We have this situation on many servers - used versions are 9.1.14 and/or > 9.3.6, on Linux servers. > > There is a table, with ~ 1 million rows. > There are no deletes there, inserts happen at the rate of ~ 100-200 > daily (but not spread, it's usually a single moment in day where there > happen the inserts). > There is also HUGE number of updates - up to 200,000 rows updated per > hour. Are the columns that are included in the bloated index also updated that often? If not, I'd suggest moving those columns to a separate table with a one-to-one relationship to the main table. Or perhaps just create a helper table that contains copies of those columns, and keep it up-to-date with triggers. That would reduce the churn in the index. > On these databases we have some (not many) 1-2 minute transactions, but usually > every transaction within 30 seconds > > This table is vacuumed (autovacuum) quite a lot, usually at least 10 times a > day. > > Is there anything we could do to help diagnose the problem, and fix it? > I don't think I can install custom pg version, and downtime would be > complicated to get approval, but anything about the data/database I can > check that would allow diagnosing the bug, I'd be happy to do. GiST doesn't have the same features that e.g B-tree has to avoid bloat: 1. When GiST has multiple equally good choices where it could insert a tuple, it favours branches that are "earlier" in the index. Always descending down the same branch is good for cache efficiency when you insert multiple items with similar keys, but the downside is that the other branches can easily have a lot of free space that goes unused, while the "hot" branch just gets split repeatedly. This is explained in the comments in the gistchoose() function. That leads to bloat, because the free space isn't being used. 2. When an index page becomes completely empty, GiST doesn't try to remove and reuse it. It would be nice to address those in a future version, but that won't help you right now. - Heikki -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs