Advice on Contiguous IDs

From: "Brian McKiernan" <brian(dot)mckiernan(at)firstcircle(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: Advice on Contiguous IDs
Date: 2018-01-09 09:06:26
Message-ID: 5a546fcab6ae2e0000bdb8e4@polymail.io
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

Hi Folks,

Looking for some help/advice - not sure if this is the appropriate channel.

My Issue:
My primary keys in a certain table are not contiguous.

What I have done so far:
I have checked the documentation and found: https://wiki.postgresql.org/wiki/FAQ#Why_are_there_gaps_in_the_numbering_of_my_sequence.2FSERIAL_column.3F_Why_aren.27t_my_sequence_nu ( https://wiki.postgresql.org/wiki/FAQ#Why_are_there_gaps_in_the_numbering_of_my_sequence.2FSERIAL_column.3F_Why_aren.27t_my_sequence_numbers_reused_on_transaction_abort.3F )
mbers_reused_on_transaction_abort.3F ( https://wiki.postgresql.org/wiki/FAQ#Why_are_there_gaps_in_the_numbering_of_my_sequence.2FSERIAL_column.3F_Why_aren.27t_my_sequence_numbers_reused_on_transaction_abort.3F )

My Question:
1) What event would cause the CACHE clause in CREATE SEQUENCE to make an out of sequence next number?
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?

Many thanks in advance,
Brian

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2018-01-09 13:05:42 Describe UNION's cast on derived table
Previous Message Simon Riggs 2018-01-06 18:15:15 Re: Is this still accurate?