From: | Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> |
---|---|
To: | Dmitry Koterov <dmitry(dot)koterov(at)gmail(dot)com> |
Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to create "auto-increment" field WITHOUT a sequence object? |
Date: | 2011-06-30 23:23:19 |
Message-ID: | 4E0D0567.8080705@postnewspapers.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 07/01/2011 02:20 AM, Dmitry Koterov wrote:
>
> The problem is that these INSERTs are rolled back oftenly (i.e. they
> are executed within a transaction block which is rolled back time to
> time), this is an existing design of the current architecture and
> unfortunately we have to live with it. And I need as compact uniq_id
> generation (with minimum "holes") as it possible - this is a VERY
> important requirement (to export these values into external systems
> which accepts only IDs limited from 1 to 100000).
What you want is often referred to as a "gapless sequence". Searching
the mailing list archives for that will find you lots of information.
> but seems it performs too hard locking - time to time this query is
> timed out (or sometimes deadlocks with other queries).
You'll have that problem with any gapless sequence approach. You'll have
to be prepared to re-try failed transactions after deadlocks, or be
*extremely* strict about the order in which you perform operations so
you avoid any deadlocks.
--
Craig Ringer
From | Date | Subject | |
---|---|---|---|
Next Message | Casey Havenor | 2011-06-30 23:43:32 | Re: Inheritence issue scheme advice? |
Previous Message | Craig Ringer | 2011-06-30 23:20:24 | Re: Contrib source |