From: Ron Johnson <ron.l.johnson@cox.net>
To: PgSQL Performance ML <pgsql-performance@postgresql.org>
Subject: Re: Selecting random rows efficiently
Date: Sat, 30 Aug 2003 11:18:25 -0500
Message-ID: <1062260304.669.566.camel@haggis> (raw)
In-Reply-To: <1062252117.83670.29.camel@jester>
References: <Pine.BSF.4.44.0308300905390.829-100000@torgo.978.org>
<200308301425.51127.rj@last.fm>
<1062252117.83670.29.camel@jester>
On Sat, 2003-08-30 at 09:01, Rod Taylor wrote:
> > i was hoping there was some trickery with sequences that would allow me to
> > easily pick a random valid sequence number..?
>
> I would suggest renumbering the data.
>
> ALTER SEQUENCE ... RESTART WITH 1;
> UPDATE table SET pkey = DEFAULT;
>
> Of course, PostgreSQL may have trouble with that update due to
> evaluation of the unique constraint immediately -- so drop the primary
> key first, and add it back after.
And if there are child tables, they'd all have to be updated, too.
--
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA
"Whatever may be the moral ambiguities of the so-called
demoratic nations and however serious may be their failure to
conform perfectly to their democratic ideals, it is sheer moral
perversity to equate the inconsistencies of a democratic
civilization with the brutalities which modern tyrannical states
practice."
Reinhold Nieburhr, ca. 1940
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: ron.l.johnson@cox.net
Subject: Re: Selecting random rows efficiently
In-Reply-To: <1062260304.669.566.camel@haggis>
References: <Pine.BSF.4.44.0308300905390.829-100000@torgo.978.org> <200308301425.51127.rj@last.fm> <1062252117.83670.29.camel@jester> <1062260304.669.566.camel@haggis>
* 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