> > Now I read this paragraph, I realize I was not clear enough. > > I am saying we do not want to use locks because of all the problems > > described. > > And what I was asking is what locking where you doing? > > And it might be better to ask the list how to solve those problems, then > to create a whole new set of problems by using millions of sequences. > > What we are doing in the **OTHER section** with row locks is basically:
BEGIN; ... x = SELECT last_value + 1 FROM counter WHERE group = ... AND element = .... FOR UPDATE; ... if everything is fine, then: UPDATE counter SET last_value = x WHERE group = ... AND element = .... FOR UPDATE; COMMIT; else: ROLLBACK;