Possible Duplicate:
is there a way to avoid calling nextval() if the insert fails in PostgreSQL?
Rails - Postgres does not re-use deleted ids but MySql does?
I have very simple database with PostgreSQL 9.2.1. When i insert something with Doctrine2 by using this method:
$em->persist($entity);
$em->flush();
If I get an error
-means record NOT inserted-
it still adds 1
to my primary key. So if i refresh the page 50
times, it says auto increment value is set to 50
. How can I prevent this? If record not insterted than why primary key increases. This is very critical because it uses indexes for nothing and the number keep going bigger.
I have no idea what it came from and why, so, i did not tried anything. Very stuck at this point.