Re: Bigger sequences (int8)

From: "Bryan White" <bryan(at)arcamax(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bigger sequences (int8)
Date: 2000-06-20 17:57:12
Message-ID: 00ec01bfdae0$f6529540$2dd260d1@arcamax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Can I make a sequence use an int8 instead of int4?
>
> I have an application where, over a few years, it's quite possible to hit
> the ~2 billion limit. (~4 billion if I start the sequence at -2
> billion.)
>
> There won't be that many records in the table, but there will be that many
> inserts. In other words, there will be many deletes, as well.
>
> If I CYCLE, old record could still be lingering, and I have the overhead
> of checking every NEXTVAL to make sure it's not already being used. :-(
>
> Any other ideas? I could use two int4's together as primary key, and do
> some crazy math to increment, or jump through other hoops (besides CYCLE)
> to intelligently reuse keys ... but then I have some ugly overhead, as
> well.
>
> I really want the sequence to just be an int8. Are we talking about a
> heinous amount of work in the source code to allow this option? I
> wouldn't want to mess with the "CREATE SEQUENCE" syntax; it would seem
> more appropriate as a compile-time option.

I'm no expert on the backend but it seems to me you would not even have to
change the syntax. The maxval defaults to 2 billion. For an int8 sequence
just specify max val greater than that. Actually it may make the most sence
to always use 64 bit values for the sequence. Just leave the default ranges
in place for compatibility.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carsten Huettl 2000-06-20 18:50:10 Postgres with php3
Previous Message Steve Wolfe 2000-06-20 17:55:18 Re: Backend died while dropping index