From: Bruno Wolff III <bruno@wolff.to>
To: Michael Artz <mlartz@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Storing an ordered list
Date: Thu, 27 Jul 2006 08:18:23 -0500
Message-ID: <20060727131823.GA30179@wolff.to> (raw)
In-Reply-To: <e9c163070607261713j21d8e9a1n2e2ea25bd30de39c@mail.gmail.com>
References: <e9c163070607251958x2ef2a315w4204aa2f90e70bbe@mail.gmail.com>
<20060726203954.GA23437@wolff.to>
<e9c163070607261713j21d8e9a1n2e2ea25bd30de39c@mail.gmail.com>
On Wed, Jul 26, 2006 at 20:13:03 -0400,
Michael Artz <mlartz@gmail.com> wrote:
> On 7/26/06, Bruno Wolff III <bruno@wolff.to> wrote:
> >If you use numeric instead of int, then it is easy to insert new values.
>
> Hmm, hadn't thought about that. How would you normally implement it?
> I'm thinking that, if I wanted to insert between A and B, I could take
> (A.order + B.order)/2, which would be pretty simple. Is there a
> better way?
I think that will depend. To keep the size of the number down, you will
probably want to use the number with the fewest digits to the right of the
decimal point that gives you a number between the two values. That will be
a bit more complicated than the above formula. But you will want to do
something to keep the size of the numerics down since it seems like reordering
will be common.
Another issue to consider is concurrency. You may want to lock the table
against concurrent reordering, as doing two at once may lead to some unexpected
events.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, mlartz@gmail.com
Subject: Re: Storing an ordered list
In-Reply-To: <20060727131823.GA30179@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox