Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZWniL-0003IK-7X for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2015 15:43:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZWniK-0000me-Q7 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2015 15:43:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZWnh2-0007jI-Ko for pgsql-hackers@postgresql.org; Tue, 01 Sep 2015 15:41:52 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZWngz-0007av-0O for pgsql-hackers@postgresql.org; Tue, 01 Sep 2015 15:41:52 +0000 Received: by wicmc4 with SMTP id mc4so37671181wic.0 for ; Tue, 01 Sep 2015 08:41:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=actpKGul/BE8N6BU8RXDxGgCJztpofKc0zXmh/AK9Kc=; b=AXNqKpm/kTC39Jlis44Xfjw6iEYac5KLuUsmT5K14ncDhXrrAv5btYz17ngWy6Gcy4 cRKg8i+wssj85FvHXUMVG7NNyQlcQAkYwRf6Ev6V2QRrDqA+yHT5GB6DQTTU9iFA0j+g XABnP46qgkT4x+9GA+pOWnsyx6k9erWXtocVUKTWKUfZqmtz66QiPPA5r4SnJGX8TjEg f3hdjaxtV5Y/iYRU3Vbwbf9VZaYpYQovA7HgQGuK5rc+f5WhU73ljSHRzq9TTUMyOcft ziUD0Bze0B8sYliGnXBWNmlyqJD9VeNcMueUO4wNvhQjYduhGa+NDilqXzv2B6hpqgoo LrKg== X-Gm-Message-State: ALoCoQmJP6ndu1mDHkXPPsn+POMeE7HvTTMGPmZcoTy5jALx2jBgw/0zIeCuI9gVy0eA2EJK4r7FojhnXUqE0UWgmR6awjtzghTweLu0fVXY8+b5I/CZRCj/bENVg4E3h7eSeCrJqEVWge356iIqfo7WoqE7z0atxv47WgbfIxSXMFihexlxYCxrk3AjxQtxEmIhuqQMWNAR X-Received: by 10.194.248.234 with SMTP id yp10mr37165966wjc.24.1441122107014; Tue, 01 Sep 2015 08:41:47 -0700 (PDT) Received: from [10.137.2.12] (ip-78-45-136-74.net.upcbroadband.cz. [78.45.136.74]) by smtp.gmail.com with ESMTPSA id d17sm27767282wjs.32.2015.09.01.08.41.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 08:41:46 -0700 (PDT) Message-ID: <55E5C737.7040603@2ndquadrant.com> Date: Tue, 01 Sep 2015 17:41:43 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Alexander Korotkov CC: pgsql-hackers Subject: Re: [PROPOSAL] Effective storage of duplicates in B-tree index. References: <55E4051B.7020209@postgrespro.ru> <55E4723D.8060101@2ndquadrant.com> In-Reply-To: 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-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 09/01/2015 11:31 AM, Alexander Korotkov wrote: ... > > Yes, In general GIN is a btree with effective duplicates handling + > support of splitting single datums into multiple keys. > This proposal is mostly porting duplicates handling from GIN to btree. > > Sure, there are differences - GIN indexes don't handle UNIQUE indexes, > > > The difference between btree_gin and btree is not only UNIQUE feature. > 1) There is no gingettuple in GIN. GIN supports only bitmap scans. And > it's not feasible to add gingettuple to GIN. At least with same > semantics as it is in btree. > 2) GIN doesn't support multicolumn indexes in the way btree does. > Multicolumn GIN is more like set of separate singlecolumn GINs: it > doesn't have composite keys. > 3) btree_gin can't effectively handle range searches. "a < x < b" would > be hangle as "a < x" intersect "x < b". That is extremely inefficient. > It is possible to fix. However, there is no clear proposal how to fit > this case into GIN interface, yet. > > but the compression can only be effective when there are duplicate > rows. So either the index is not UNIQUE (so the b-tree feature is > not needed), or there are many updates. > > From my observations users can use btree_gin only in some cases. They > like compression, but can't use btree_gin mostly because of #1. Thanks for the explanation! I'm not that familiar with GIN internals, but this mostly matches my understanding. I have only mentioned UNIQUE because the lack of gettuple() method seems obvious - and it works fine when GIN indexes are used as "bitmap indexes". But you're right - we can't do index only scans on GIN indexes, which is a huge benefit of btree indexes. > > Which brings me to the other benefit of btree indexes - they are > designed for high concurrency. How much is this going to be affected > by introducing the posting lists? > > > I'd notice that current duplicates handling in PostgreSQL is hack over > original btree. It is designed so in btree access method in PostgreSQL, > not btree in general. > Posting lists shouldn't change concurrency much. Currently, in btree you > have to lock one page exclusively when you're inserting new value. > When posting list is small and fits one page you have to do similar > thing: exclusive lock of one page to insert new value. > When you have posting tree, you have to do exclusive lock on one page of > posting tree. OK. > > One can say that concurrency would became worse because index would > become smaller and number of pages would became smaller too. Since > number of pages would be smaller, backends are more likely concur for > the same page. But this argument can be user against any compression and > for any bloat. Which might be a problem for some use cases, but I assume we could add an option disabling this per-index. Probably having it "off" by default, and only enabling the compression explicitly. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers