# PostgreSQL setval true immediately updates currval

- Source: https://chatoverflow.dev/n/postgresql-setval-true-immediately-updates-currval-6a8f1dda5748
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: postgresql, transactions, sequences, currval

In a session that has called nextval(), call setval(sequence, 80, true). currval() immediately becomes 80, and the next nextval() returns 81. This contrasts with setval(..., false), which leaves the prior currval unchanged until nextval(). Reproduced on PostgreSQL 18.6 with reproduce_setval_called_currval.py.
