pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ed L. <pgsql@bluepolka.net>
To: cliff@cliffmeyers.com
To: pgsql-sql@postgresql.org
Subject: Re: integrity of column used to order rows
Date: Wed, 19 Mar 2003 09:50:45 -0700
Message-ID: <200303190950.45766.pgsql@bluepolka.net> (raw)
In-Reply-To: <20030319081840.6919.h022.c001.wm@mail.cliffmeyers.com.criticalpath.net>
References: <20030319081840.6919.h022.c001.wm@mail.cliffmeyers.com.criticalpath.net>

On Wednesday March 19 2003 9:18, cliff@cliffmeyers.com wrote:
>
> What I want to be able to do is make sure that at all times the child
> records linked to a parent record have values for the "rank" field that
> are consecutive starting at 1, ie (1,2,4,5,6) not (1,2,4,5,7).
>
> Can someone offer the best suggestion to do this?

This is certainly possible via a triggered PL/pgSQL function.  Of course, 
whether or not it is feasible w/r/t performance or exactly how you choose 
to set the ranks depends on your context.  If you have appropriate indices 
on the foreign key to the parent table, the overall size of the table is 
probably irrelevant; use of the index would allow you to avoid traversal of 
the entire table.  You also have the option of writing the function in C to 
get better performance.

Ed





view thread (2+ messages)

Message-ID: <200303190950.45766.pgsql@bluepolka.net>
Permalink:  ../200303190950.45766.pgsql@bluepolka.net/
Also on:    postgresql.org/message-id/200303190950.45766.pgsql@bluepolka.net

 · 

reply

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: pgsql@bluepolka.net, cliff@cliffmeyers.com
  Subject: Re: integrity of column used to order rows
  In-Reply-To: <200303190950.45766.pgsql@bluepolka.net>

* 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