Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZDZn-0000xA-Bq for pgsql-docs@arkaria.postgresql.org; Wed, 10 Jan 2018 10:25:43 +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 1eZDZl-0005NY-4U for pgsql-docs@arkaria.postgresql.org; Wed, 10 Jan 2018 10:25:41 +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 1eZDZk-0005NN-JO for pgsql-docs@lists.postgresql.org; Wed, 10 Jan 2018 10:25:40 +0000 Received: from mail-io0-x232.google.com ([2607:f8b0:4001:c06::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eZDZg-0007uV-9I for pgsql-docs@postgresql.org; Wed, 10 Jan 2018 10:25:38 +0000 Received: by mail-io0-x232.google.com with SMTP id c17so229203iod.1 for ; Wed, 10 Jan 2018 02:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=firstcircle-com.20150623.gappssmtp.com; s=20150623; h=mime-version:to:message-id:subject:date:in-reply-to:references:from; bh=3Dz4b8w/CfNo61JEQzauyBjlJ9wiIB3mCDdt2TRGtIE=; b=NGmTwI9YbHCeWmUzdriMgfnwuhHsPaP1mrfISTGHJhyhUXS/8yyNBSpVwgtZtiJu7m VhCEF+RbzM8L2xm3+kEw0o/v4ozTb93uqGOFLO5a1I03eG6tjVXwMyTv/uJqa2P7lmSN 66Nds6VzNsU0+oA+UEqrK2SzGrKiwb/MlmI7BxLTdonlHhMOJTPQ/DJTpY4KX4R+lp/U cnVIuEH82ajMAdJtX4D2M2GO9d4I+b7ZA1Fo8MpIMdI7bR8UxrXBQ64qIhPpJIIrHgRJ LSrUm9DYQOzy3Q3J8BpBSpggdNuUB9oXBhwssZpz/BXmmHGXfniwpzxlWKB04J4ldOTK 0o4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:to:message-id:subject:date :in-reply-to:references:from; bh=3Dz4b8w/CfNo61JEQzauyBjlJ9wiIB3mCDdt2TRGtIE=; b=jJd+utBkBdRY//jZaCWJZfxM3ahduLU54wxGp1GmUXBzXONUAXxUiGLD6FkwPnDz6f 1dlK3Gi4FHJ4lxpElyVm5VHD7w7tI7jKTj/zypiclkzjq/cKjXBkMBZZgxRQfwmPZRdQ bItXrjysMqcWWSuGZy+EqNwq1pc4XipUZJ1P0D/BW0Kn9/c0PkSKk/QPCPcD12iEgf8b 9ehuTBYnMQBDMzT3Df6sFJ8FnF/WjJMBLvFpm/FMeNDMm/Tu1z6aVYlxEfclPsTGEMuG y7vqVDPY2JKi+YsX9KZLRseczBX8gKMYnmCR8BzTMLsnK2N43q8VdpyCF481N7w8Z4v6 nS6w== X-Gm-Message-State: AKGB3mIza6ZM6MVLV/Gq+lfMjV/irjKSARVUrBLN1+yNyUvhabWBZSIY xi4CzJ4eftfqPlKNZWc/jLvyHO7s3Cw= X-Google-Smtp-Source: ACJfBosf5kq8YNLg0qerNTZyDb3SsOxLVMfGzZWok8Lp3ytTAhQNM0lbM6a0bdpn22rl244gCvUKAg== X-Received: by 10.107.57.3 with SMTP id g3mr18616895ioa.297.1515579933966; Wed, 10 Jan 2018 02:25:33 -0800 (PST) Received: from localhost (235.205.188.35.bc.googleusercontent.com. [35.188.205.235]) by smtp.gmail.com with ESMTPSA id d5sm9842307ioc.75.2018.01.10.02.25.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 02:25:33 -0800 (PST) Mime-Version: 1.0 To: "Vik Fearing" , pgsql-docs@postgresql.org Message-ID: <5a55e9c44a197700005f0ec1@polymail.io> Subject: Re: Advice on Contiguous IDs Date: Wed, 10 Jan 2018 02:25:24 -0800 In-Reply-To: References: X-Mailer: Polymail From: "Brian McKiernan" Content-Type: multipart/alternative; boundary=52df1f4f88b1b8167ac8e657f06cd1223f3f09aa3272f8c36b449ad931eb List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --52df1f4f88b1b8167ac8e657f06cd1223f3f09aa3272f8c36b449ad931eb Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Thanks folks - extremely insightful. Much appreciated. Brian On Wed 10 Jan 2018 at 01:33 Vik Fearing < Vik Fearing ( Vik Fearing ) > wrote: >=20 >=20 >=20 > 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. >=20 > It is not. You want the pgsql-general list, or perhaps pgsql-novice. >=20 > > My Issue: > > My primary keys in a certain table are not contiguous. >=20 > 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? >=20 > > My Question: > > 1) What event would cause the=C2=A0CACHE clause in CREATE SEQUENCE to m= ake an >=20 > > out of sequence next number? >=20 > 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. >=20 > > 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? >=20 > 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 >=20 >=20 > --52df1f4f88b1b8167ac8e657f06cd1223f3f09aa3272f8c36b449ad931eb Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8 3D""
Thanks folks - extremely insightful.

Much appreciated.

Brian<= /div>


= On Wed 10 Jan 2018 at 01:33 Vik Fearing <<= a href=3D"mailto:Vik Fearing <vik.fearing@2ndquadrant.com>">Vik Feari= ng > wrot= e:
On 01/09/2018 10:06 AM, Brian McKiernan wrote:
> Hi Folks,
>=20
> 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 car= e?

> 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 s= o
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 creat= e
> contiguous primary key IDs then performance will greatly suffer? D= o we
> have an idea of how bad this will generally be or what does that d= epend
> upon?

Performance itself doesn't really suffer, concurrency does. If you hav= e
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.
--=20
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr Postgre= SQL : Expertise, Formation et Support


--52df1f4f88b1b8167ac8e657f06cd1223f3f09aa3272f8c36b449ad931eb--