Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5RDG-00039b-S7 for pgsql-performance@arkaria.postgresql.org; Wed, 25 May 2016 05:18:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1b5RDF-0003vV-St for pgsql-performance@arkaria.postgresql.org; Wed, 25 May 2016 05:18:33 +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 1b5RDF-0003vI-1V for pgsql-performance@postgresql.org; Wed, 25 May 2016 05:18:33 +0000 Received: from mail-oi0-x22b.google.com ([2607:f8b0:4003:c06::22b]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1b5RD9-0001Wo-Sk for pgsql-performance@postgresql.org; Wed, 25 May 2016 05:18:31 +0000 Received: by mail-oi0-x22b.google.com with SMTP id w184so54551864oiw.2 for ; Tue, 24 May 2016 22:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+sHE24h2dbKhceZB7+8QYvh6OEgJGUrm+pN8RFiRl0s=; b=CUd81fJjw1ZaQQ5ndEwCvJvNUfBqQuUlcs+e0DkAdyDseM24xlERpN2WySrWaFotob GzgdVepa4nKNwWxAHk9BH6DxSMfrN9ixGKC4bmzkUoAXTRROt+yqYLlHiFW4os23eGfn jeruS0jMvXiiXajmT8u6PQwCfRm0XSeTPKdmLordACNB5XQlkEOqcjaMTObNuWsNLYHw gi1AkxHtC6s8CtMRImGoHmj6ANEY+rQQEgQs1aRe2sw7Jln1befR7/KTb58AE1za8JhA sV9z3knlgQtxdZqU4kNcVbIIDizqzU93wzxYkmNn592h8Ig8h01vOhbXnUhJb82yyMIs pzZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+sHE24h2dbKhceZB7+8QYvh6OEgJGUrm+pN8RFiRl0s=; b=gHRGAd4IqOVQR8Op1dWcdFYImE52tXMocTTKCrT+zrf5sS2TOU4YCyZ1nFyVy4RZEl xxromf08PKxOKqY1VDpsNN5vHdz825s+GFOjwT9Uj9r0EF31BS4rVx4F+2KYlm2fDhgj ocgyp8MH+e1GFGsnxh5dbAb/XBqGyw8cZSZ+jH4zTbIaK0N7fkF8m8+pCdCg3XhX4Mci +5vsAwyIEHaljaH4RtT5wDLs+3wpLKmFU+f8/SqSkpy+wNbdL+QrP8MMmJ6eFjhmKLIs mF7F7ZUCAEK9w34yBeesEnATEWFDyy18UhmlmtF6yzxPX4QPN3e063j+Fa7aOuyZD7bP /tiA== X-Gm-Message-State: ALyK8tI4yBdALq96KvLQV06TZkR1hIYHqjQz2gvwioT425PuocvzxYU60GSS53Elwx80DLAMD/aMYfxYpgEE7g== X-Received: by 10.202.168.143 with SMTP id r137mr1138152oie.40.1464153505670; Tue, 24 May 2016 22:18:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.17.74 with HTTP; Tue, 24 May 2016 22:18:06 -0700 (PDT) X-Originating-IP: [75.101.100.201] In-Reply-To: <4117.1464151388@sss.pgh.pa.us> References: <20160524173914.GA11880@telsasoft.com> <4117.1464151388@sss.pgh.pa.us> From: Peter Geoghegan Date: Tue, 24 May 2016 22:18:06 -0700 Message-ID: Subject: Re: index fragmentation on insert-only table with non-unique column To: Tom Lane Cc: Justin Pryzby , pgsql-performance@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On Tue, May 24, 2016 at 9:43 PM, Tom Lane wrote: > Yeah. I wonder what would happen if we used the same rule for index > insertions. It would likely make insertions more expensive, but maybe > not by much. The existing "randomization" rule for where to insert new > items in a run of identical index entries would go away, because the > insertion point would become deterministic. I am not sure if that's > good or bad for insertion performance, but it would likely help for > scan performance. I think that if somebody tacked on a tie-breaker in the same way as in tuplesort.c's B-Tree IndexTuple, there'd be significant negative consequences. The equal-to-high-key case gets a choice of which page to put the new IndexTuple on, and I imagine that that's quite useful when it comes up. I'd also have concerns about the key space in the index. I think that it would seriously mess with the long term utility of values in internal pages, which currently can reasonably have little to do with the values currently stored in leaf pages. They're functionally only separators of the key space that guide index scans, so it doesn't matter if the actual values are completely absent from the leaf pages/the table itself (perhaps some of the values in the internal pages were inserted years ago, and have long since been deleted and vacuumed away). Provided the distribution of values at the leaf level is still well characterized at higher levels (e.g. many string values that start with vowels, very few that start with the letters 'x' or 'z'), there should be no significant bloat. That's very valuable. Unique indexes are another problem for this naive approach. Maybe somebody could do better with a more sophisticated approach, but it's probably better to focus on duplicate storage or even leaf page compression, as Stephen mentioned. -- Peter Geoghegan -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance