Skip site navigation (1) Skip section navigation (2)

Re: SERIAL order and INSERT order

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: SERIAL order and INSERT order
Date: 2011-06-15 07:21:48
Message-ID: it9mhs$ovc$ (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
l1(at)nym(dot)hush(dot)com, 14.06.2011 20:30:

> Are there any cases where an observer might see a row with serial
> number 2 but not yet see serial number 1, perhaps because thread 1
> hasn't completed its insert yet?  For example SELECT * WHERE
> seqnumber<  3; would return only a row with seqnumber=2?

It is never a good idea to rely on the numeric ordering of a generated PK column. If you really need to know in which order rows were inserted you should use a timestamp that is recording that time (although I believe the resolution of a timestamp column might be not fine enough..)


In response to


pgsql-novice by date

Next:From: Bob McConnellDate: 2011-06-15 11:27:53
Subject: Re: SERIAL order and INSERT order
Previous:From: Merlin MoncureDate: 2011-06-14 19:11:44
Subject: Re: SERIAL order and INSERT order

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group