Sequence generating negative numbers

From: Shantanu Shekhar <shekharshan(at)yahoo(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Sequence generating negative numbers
Date: 2020-08-19 22:15:30
Message-ID: 2073926122.3495277.1597875330242@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Team,
I have a sequence definition in Postgres 9.6.11 like so:
CREATE SEQUENCE IF NOT EXISTS org.my_seq  INCREMENT 1  MINVALUE 1  NO MAXVALUE  START 1  CACHE 20;
This sequence is used by a Java ORM framework to generate primary keys for one of our tables. The initial numbers generated by this sequence are as shown below:
-28 -27 -26 -25 -8 -7 1 2 52 53 72 92 93 94 112 113 132 133 152 172 192 193 212

I am unable to understand why the sequence would start with a negative number, particularly when the definition explicitly asks the sequence to start at 1. This has happened consistently in all of our environments. 
Thanks,
Shantanu

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-08-19 22:20:00 Re: Sequence generating negative numbers
Previous Message Philip Semanchuk 2020-08-19 21:55:49 Understanding EXPLAIN ANALYZE estimates when loops != 1