Re: Fwd: Sizes of sequences and serials - Mailing list pgsql-general

From Tom Lane
Subject Re: Fwd: Sizes of sequences and serials
Date
Msg-id 20713.1033098983@sss.pgh.pa.us
Whole thread Raw
In response to Fwd: Sizes of sequences and serials  (elein <elein@sbcglobal.net>)
List pgsql-general
elein <elein@sbcglobal.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

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: get date in binary number format
Next
From: Tom Lane
Date:
Subject: Re: get date in binary number format