In a PostgreSQL database I have a table with a primary key and another field which needs to be unique.
CREATE TABLE users ( id INTEGER PRIMARY KEY
I don't think so: a basic feature of sequences is that gaps are possible (think of two concurrent transactions, with one performing a ROLLBACK). You should ignore gaps. Why are they a problem in your case?