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$1@dough.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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..)

Regards
Thomas

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bob McConnell 2011-06-15 11:27:53 Re: SERIAL order and INSERT order
Previous Message Merlin Moncure 2011-06-14 19:11:44 Re: SERIAL order and INSERT order