From: | Alex Pilosov <alex(at)pilosoft(dot)com> |
---|---|
To: | Vivek Khera <khera(at)kciLink(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Re: inserting, index and no index - speed |
Date: | 2001-06-11 03:48:23 |
Message-ID: | Pine.BSO.4.10.10106102341180.17529-100000@spider.pilosoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, 10 Jun 2001, Vivek Khera wrote:
> Even if your transaction fails? That seems to counter the definition
> of a transaction that aborts; the state of the database is different
> than before.
Yes, except for the sequences.
Consider this example, transactions A, B, C, sequence S.
in A S.nextval = 1
in B S.nextval = 2
in C S.nextval = 3
transaction B then aborts, A and C succeed. Then, in your logic, nextval
of S should be 2, but really, to keep this kind of state, you need a table
listing 'currently unused values'. That, when your sequence gets to
millions, is a colossal waste of space.
If you want "maximum id that's not currently used in my table" use
max(id), if you want "give me a non-repeating number", use sequence.
There also are implications on concurrency when you use max(id), as only
one transaction can do it without danger of repeating IDs.
-alex
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Pilosov | 2001-06-11 04:01:04 | Re: Getting interval in seconds? |
Previous Message | Vivek Khera | 2001-06-11 03:27:23 | Re: Re: inserting, index and no index - speed |