Do you have any code that might do a select to determine the value of the sequence used?
Example: INSERT blah blah blah; SELECT currval(sequence_name); or somethign like that? If so, the SELECT may be incrementing the counter and that would explain the jump by 2 your seeing. There is a function to determine the value of the sequence without incrementing for postgres, but I don't remember right now what that is. I actually just did something like this myself. Creating an entry in a table and then needing to find out what the entry id was. In my case, I actually ended up just doing a SELECT with a where clause including the data I just inserted, reverse sorted by record creation date (timestamp default now() kind of thing, not included in INSERT statement) with a limit of 1. I know I could have used the function to get the sequence value, but I wasn't absolutely sure what would happen. If two processes incremented the sequence at the same time, what would the function return, the value for that connection's insert, or the value of the other session? Especially when I added Apache::DBI to the mix where db connections appear to be pooled and shared. This way I know I'm getting the value I'm looking for. Greg