Relative Content

Tag Archive for postgresqlupsertsequence-sql

Postgresql upsert statement increments the sequence last_value when updating records

I noticed a postgresql table with a primary key id field of type bigserial had an id with a value in the millions but only had a COUNT showing a few hundred records. The table was being called regularly with an upsert statment similar to the following:
INSERT INTO test_table (ticker,column1) VALUES ('a','1') ON CONFLICT (ticker) DO UPDATE SET column1=EXCLUDED.column1;