While this blog has been suffering neglect, I have been experimenting with a bunch of things in the last few months. Sharing what I learnt today – When we modify the last_value of a table sequence in postgres, the changes do not reflect immediately, i.e. the next value of that column(which is populated by the sequence) does not start with the new value right away.
To quote the documentation –
“ALTER SEQUENCE will not immediately affect
nextval results in backends, other than the current one, that have preallocated (cached) sequence values. They will use up all cached values prior to noticing the changed sequence generation parameters. The current backend will be affected immediately.” – Notes section of http://www.postgresql.org/docs/9.2/static/sql-altersequence.html