FRN311[info]Types
Integer column may run out of values
integer and smallint columns hold far fewer values than bigint.
Why it's risky in PostgreSQL
An integer id or counter stops at about 2.1 billion (smallint at 32,767). Inserts then fail, and moving the column to bigint later rewrites the whole table under an ACCESS EXCLUSIVE lock.
bigint costs 4 more bytes per row and avoids that migration entirely.
What triggers it, and the safer way
CREATE TABLE events (id serial PRIMARY KEY, hits integer);CREATE TABLE events (id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, hits bigint);Suppress it when you're sure
Put this comment on the line before the statement. The reason is required and shows in the report.
-- fronelta:allow FRN311 <why this is safe here>Applies to PostgreSQL 14, 15, 16, 17.