0

I have a table named email_recipients and an ID is skipped whenever there is a duplicate in email.

CREATE TABLE email_recipients(
id SERIAL PRIMARY KEY,
email_address varchar(255) UNIQUE NOT NULL,
last_name varchar(255),
first_name varchar(255),
active boolean
);
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Alex
  • 35
  • 1
  • 10

1 Answers1

0

Yes, that is normal.

The DEFAULT value has to be evaluated before the insertion, and if the INSERT fails for any reason, the sequence value still has been consumed.

This is because sequences are non-transactional for performance reasons, which is a feature.

Don't strive for a “gap-less” sequence, it offers no benefit, only pain.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263