Re: Selecting random rows efficiently - Mailing list pgsql-performance

From Ron Johnson
Subject Re: Selecting random rows efficiently
Date
Msg-id 1062260304.669.566.camel@haggis
Whole thread Raw
In response to Re: Selecting random rows efficiently  (Rod Taylor <rbt@rbt.ca>)
Responses Re: Selecting random rows efficiently
List pgsql-performance
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


pgsql-performance by date:

Previous
From: Rob Nagler
Date:
Subject: Re: How to force Nested Loop plan?
Next
From: Tom Lane
Date:
Subject: Re: How to force Nested Loop plan?