Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYxme-0005Q4-KR for pgsql-docs@arkaria.postgresql.org; Tue, 09 Jan 2018 17:33:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eYxme-0001Qe-7c for pgsql-docs@arkaria.postgresql.org; Tue, 09 Jan 2018 17:33:56 +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 1eYxmd-0001QU-VJ for pgsql-docs@lists.postgresql.org; Tue, 09 Jan 2018 17:33:56 +0000 Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eYxmb-0002En-A9 for pgsql-docs@postgresql.org; Tue, 09 Jan 2018 17:33:54 +0000 Received: by mail-wm0-x22c.google.com with SMTP id 141so5336116wme.3 for ; Tue, 09 Jan 2018 09:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:organization:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=hq4+Dkd+jrd6SBaNXPMED0i5W+Ww2PN0jFqIiuJiD+A=; b=hFeSbAnpJJELkV/rp19C5LEbFONWgHkhnKT/Y73Vu5vkfKoju0qijn0GZbJNyGr3rT C1Xnhs5M2v7Ygoa33vUSGmZzZhR4shq0CzRXa6NBXbSs4HyF6ImRcmhjTMiq9HCaNlSA 79xFTo5Ehh49AYcBMR7NmpFb0BLWlPXBJXX1CkuQZFlh85PLbbaSTuqQRlGV5M4x5Apf fx5OLzNUDkXV4LhdkRHtpisKJfR0x6XA2jTzxtY+/msMMU77oIq036ygQBZsOfGICkKW vzmh/ZjPsj6DzHQVmoJZwagm2W15vH1QhzOM9AMQrYkOxkO+9m6WjxXtHkxFWNKSUbU+ Byag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=hq4+Dkd+jrd6SBaNXPMED0i5W+Ww2PN0jFqIiuJiD+A=; b=o5bsgBk9GWRx65uUuU5lSE4zoZFMX3pua3534jwshjR6YmCQRyvvCL9li8cdYLYBOJ ADniq7E2JhqOfxNrunihADOIyT4FOVQlxZzPbkQm1bpDwiQV88PoxGgGK6lXeALwC3cD FVn+2M3vP/0yfEFVxgol8SRTR5DBQfX88PIrVLAjeZjj1FoBtHXMLYGlwfht5H+EB5ff tzrPRZfsi568QEsmINa10ytijxb9YajjLE171QViA0Sl9u9Bsy3G6rGlgSyeyodH56LB 1IIaNuUg5T94biUUc19L5StLTLEyK6FgBmwyQCus/9jOR9woHGrr+9kGahmRawehjeTY qU5A== X-Gm-Message-State: AKGB3mKdoCkZmpnMpRsNGEX+rxHiLDO814vjRhAsD5zT/6TWPFk1xVyX 75V9CYTHvRYx3yV/fanpHFhFsv/mQbAaD731cPTlwx/0HnR3tNG4mOBw5mNcG7LGoIDK9eBvnhm r79yThXEwmJyNpB/KfAKo4AAJcKAARX7+YH+yMTKQfIUS+elySAfu2bXLrwiz1NB72i1SHCiLyV PE2awbLQ== X-Google-Smtp-Source: ACJfBoudAfSWGXSJ0PShQBToYvenkTrFO/ESVwEsEBjHYSA+qNWQVxBspd/5e/nRAxNjkC+V3VXteA== X-Received: by 10.28.68.134 with SMTP id r128mr13561812wma.60.1515519231080; Tue, 09 Jan 2018 09:33:51 -0800 (PST) Received: from [192.168.0.3] (ath91-3-88-167-161-184.fbx.proxad.net. [88.167.161.184]) by smtp.gmail.com with ESMTPSA id p15sm12999126wre.64.2018.01.09.09.33.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 09:33:50 -0800 (PST) Subject: Re: Advice on Contiguous IDs To: Brian McKiernan , pgsql-docs@postgresql.org References: <5a546fcab6ae2e0000bdb8e4@polymail.io> From: Vik Fearing Organization: 2ndQuadrant France Message-ID: Date: Tue, 9 Jan 2018 18:33:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <5a546fcab6ae2e0000bdb8e4@polymail.io> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 01/09/2018 10:06 AM, Brian McKiernan wrote: > Hi Folks, > > Looking for some help/advice - not sure if this is the appropriate channel. It is not. You want the pgsql-general list, or perhaps pgsql-novice. > My Issue: > My primary keys in a certain table are not contiguous. Is that really an issue? The only valid case of gapless sequences I've ever seen is invoice numbers. If you're not doing that, why do you care? > My Question: > 1) What event would cause the CACHE clause in CREATE SEQUENCE to make an > out of sequence next number? If the server crashes, it can jump ahead by up to 32 values. This is so sequences don't have to be WAL logged every single time which could be quite slow. > 2) In all cases am I correct in my thinking that in order to create > contiguous primary key IDs then performance will greatly suffer? Do we > have an idea of how bad this will generally be or what does that depend > upon? Performance itself doesn't really suffer, concurrency does. If you have a lot of concurrent inserts on this table, then global performance will indeed be worse than if you didn't care about gaps. If it's just one process doing the insert, you won't notice any performance drop at all. -- Vik Fearing +33 6 46 75 15 36 http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support