Re: How to create "auto-increment" field WITHOUT a sequence object?

From: Dmitry Koterov <dmitry(at)koterov(dot)ru>
To: "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to create "auto-increment" field WITHOUT a sequence object?
Date: 2011-06-30 19:01:13
Message-ID: BANLkTin_vmvijrC41dkv4X1Bq9zAxKjzdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you.

It may not be "fully" gapless. The main cause is to keep uniq_id as low as
it could be to not to exhaust 100000 values too fast.
I think solutions with addition tables look too complicated for this case,
is there a possiblilty to not to use an additional table?

On Thu, Jun 30, 2011 at 10:55 PM, A.M. <agentm(at)themactionfaction(dot)com> wrote:

>
> On Jun 30, 2011, at 2:40 PM, Dmitry Koterov wrote:
>
> > Hello.
> >
> > I need to create an auto-increment field on a table WITHOUT using
> sequences:
>
> This problem pops up a lot for invoice sequence numbers for the tax office
> and related cases. (Search for "gapless sequence".)
>
> Since the numbers are really only needed for an external system (as you
> mention), then it may make sense to generate the gapless IDs when necessary
> and map the generated IDs to the rows later. The drawback is that some rows
> in the table will not have the gapless ID until the batch job is run, but
> all rows will still be addressable by the real sequence ID.
>
> Cheers,
> M
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message George Weaver 2011-06-30 19:05:04 Re: How to create "auto-increment" field WITHOUT a sequence object?
Previous Message A.M. 2011-06-30 18:55:30 Re: How to create "auto-increment" field WITHOUT a sequence object?