Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZWQz9-0002ka-Le for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Aug 2015 15:27:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZWQz9-0000zj-5w for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Aug 2015 15:27:03 +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) (envelope-from ) id 1ZWQz8-0000za-71 for pgsql-hackers@postgresql.org; Mon, 31 Aug 2015 15:27:02 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZWQz4-0003Qu-Kq for pgsql-hackers@postgresql.org; Mon, 31 Aug 2015 15:27:00 +0000 Received: by wicjd9 with SMTP id jd9so3889007wic.1 for ; Mon, 31 Aug 2015 08:26:56 -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 :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=wmFxDV2cQci0BN31mStmcOeP+eNXP9lQ7BSgwDynLnw=; b=dSBQZQX7MwEvAtDbGB6MIDr8vYL8L8AcyZuNTdiceHa2LcK5lOI7RNy5McjP/QvTzJ EXS7k7oVeS3UusZIG/bJKZ5EoFhfwmcV8h3+/2p8VDKMNTIaHzS4Y6V2AH4rP3aalZ2L FhOjmdkLHxv7P8BUXvh1JFECLGzYJq6sKp8aELQUj5FLDYPfbVrVDxM1FnxArHgHaVIW fvGF3TpSO0Mly+f5H2Tj9+HcT011erE3Mae/Tp1CCGc7RsSRw/+6+gXh0aX5zmOEteBA EJdP/FJwFRmc58r/nqBhS+chwelyMeLDN1/pOIigyABzdo9UpWN7btnCQ+2aHA0zy0gj 0GQg== X-Gm-Message-State: ALoCoQmEt8XgTWRQCYMz/N+zM6Yal/J07J3DPUrWHfkuvV8OsQe976ZHNSDyOaRf6wt48w4lmT29H1v5ZGLUNtcT81wYePvCvLAuQjf28/IoXjorj54FAPUYXsrOiQrrpxLZa7EiKhawlnXJvxjmMvE8Hs4kbrqWy7ULpKEG5U76aOrz1EFoDncEZINCmC6fZ1v7EqRwwYJX X-Received: by 10.180.109.17 with SMTP id ho17mr16484642wib.34.1441034816689; Mon, 31 Aug 2015 08:26:56 -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 ej5sm22722709wjd.22.2015.08.31.08.26.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 08:26:55 -0700 (PDT) Message-ID: <55E4723D.8060101@2ndquadrant.com> Date: Mon, 31 Aug 2015 17:26:53 +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: pgsql-hackers@postgresql.org Subject: Re: [PROPOSAL] Effective storage of duplicates in B-tree index. References: <55E4051B.7020209@postgrespro.ru> In-Reply-To: <55E4051B.7020209@postgrespro.ru> 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 Hi, On 08/31/2015 09:41 AM, Anastasia Lubennikova wrote: > Hi, hackers! > I'm going to begin work on effective storage of duplicate keys in B-tree > index. > The main idea is to implement posting lists and posting trees for B-tree > index pages as it's already done for GIN. > > In a nutshell, effective storing of duplicates in GIN is organised as > follows. > Index stores single index tuple for each unique key. That index tuple > points to posting list which contains pointers to heap tuples (TIDs). If > too many rows having the same key, multiple pages are allocated for the > TIDs and these constitute so called posting tree. > You can find wonderful detailed descriptions in gin readme > > and articles . > It also makes possible to apply compression algorithm to posting > list/tree and significantly decrease index size. Read more in > presentation (part 1) > . > > Now new B-tree index tuple must be inserted for each table row that we > index. > It can possibly cause page split. Because of MVCC even unique index > could contain duplicates. > Storing duplicates in posting list/tree helps to avoid superfluous splits. > > So it seems to be very useful improvement. Of course it requires a lot > of changes in B-tree implementation, so I need approval from community. In general, index size is often a serious issue - cases where indexes need more space than tables are not quite uncommon in my experience. So I think the efforts to lower space requirements for indexes are good. But if we introduce posting lists into btree indexes, how different are they from GIN? It seems to me that if I create a GIN index (using btree_gin), I do get mostly the same thing you propose, no? Sure, there are differences - GIN indexes don't handle UNIQUE indexes, 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. 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? kind 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