Re: How to create "auto-increment" field WITHOUT a sequence object?

From: Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr>
To: Dmitriy Igrishin <dmitigr(at)gmail(dot)com>
Cc: Chris Travers <chris(dot)travers(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to create "auto-increment" field WITHOUT a sequence object?
Date: 2011-07-03 14:04:04
Message-ID: 1309701844.4502.18.camel@asus-1001PX.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le vendredi 01 juillet 2011 à 12:28 +0400, Dmitriy Igrishin a écrit :

> Then I don't clearly understand the existence of locks (the LOCK
> command, SELECT FOR UPDATE clause and so on) if the usage
> of them gives only problems...
>

Chris already explained why twice :

"you MUST lock on insert to get gapless sequences"

Can't you just :
-create the records with a regular sequence, that will have gaps
-when you want to export, number an additional column from 1 to 10 000
and use that as key
?
--
Vincent Veyron
http://marica.fr/
Logiciel de gestion des sinistres et des contentieux pour le service juridique

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitriy Igrishin 2011-07-03 14:10:08 Re: How to create "auto-increment" field WITHOUT a sequence object?
Previous Message Craig Ringer 2011-07-03 12:49:56 Re: out of memory error