RE: postgresql duplicate key violates unique constraint

Warren Seltzer wrote:

I think the requirement to manually reset the index is a bug in
postgresql. Either in
implementation or design.

I've never needed to do that. I wonder why...would autovacuum help?

Best,

I ran into this issue when I backuped a database and restored it back
into another system.

I ran into this issue when I backuped a database and restored it back
into another system.

You might want to look into how that database got backed up. By default (at least every where I've done it) pg_dump will include the statements necessary to "reset" the sequences... that is, all my dumps have lines like this:

SELECT pg_catalog.setval('banners_id_seq', 6, true);

Might be you're missing that or missing the permissions to set that.

-philip