Re: Fwd: Sizes of sequences and serials

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: elein(at)norcov(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Fwd: Sizes of sequences and serials
Date: 2002-09-27 03:56:23
Message-ID: 20713.1033098983@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

elein <elein(at)sbcglobal(dot)net> writes:
> According to the documentation, it looks like sequences
> are always stored as bigints (if the platform supports them).

Correct.

> Serials, though, seem to be able to be declared as serial
> with integer storage or serial8 for bigint storage.

> Is the storage for ordinary serials really an int and not
> a big int?

If you declare a serial (aka serial4) column, you get an int4 column
that's driven by a bigint sequence. No problem except for a runtime
conversion from int8 to int4, which is really pretty negligible in
comparison to the cost of nextval().

> Is there a way to create a sequence stored as an int instead of a big
> int?

No; it wouldn't save anything anyway, seeing that each sequence is
stored as a separate table and so must occupy one disk block.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-09-27 03:58:20 Re: postmaster -d option (was Re: [GENERAL] Relation 0 does
Previous Message Alvaro Herrera 2002-09-27 03:31:06 Re: get date in binary number format