Search code examples
databasepostgresqlperformanceauto-incrementpostgresql-serial

BIGSERIAL vs SERIAL in PostgreSQL


I'm new on PostgreSQL for auto-increment we have to use BIGSERIAL or SERIAL, so can anyone please explain which one we have to use when creating a table. Which one be the best please explain scenario wise.


Solution

  • From the docs:

    serial      4 bytes     autoincrementing integer        1 to 2147483647
    bigserial   8 bytes     large autoincrementing integer  1 to 9223372036854775807