Skip to content

Postgres Caveats

Integer Autoincrement ID#

Using Integer as the id field for a table is bad because changing it to BIGINT needs downtime or tricky constraint changes.

psycopg2.errors.SequenceGeneratorLimitExceeded: nextval: reached maximum value of sequence "my_id_seq" (2147483647)

Sometimes to avoid this issue a composite key can be used - using fields from the table as the unique identifier.

Especially happens when using a insert_on_conflict_update.

Safe and Unsafe Operations on Production#

Postgres: Safe and Unsafe Postgres Operations