From: Russell Garrett <rg@tcslon.com>
To: PgSQL Performance ML <pgsql-performance@postgresql.org>
Subject: Re: Selecting random rows efficiently
Date: Sat, 30 Aug 2003 18:43:22 +0100
Message-ID: <MKEGJINFADFODDNOKEJCGEGOEAAA.rg@tcslon.com> (raw)
In-Reply-To: <1062260304.669.566.camel@haggis>
Considering that we'd have to index the random field too, it'd be neater in
the long term to re-number the primary key. Although, being a primary key,
that's foreign-keyed from absolutely everywhere, so that'd probably take an
amusingly long time.
...and no we're not from Micronesia, we're from ever so slightly less exotic
London. Though Micronesia might be nice...
Russ (also from last.fm but without the fancy address)
pgsql-performance-owner@postgresql.org wrote:
> 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.
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: rg@tcslon.com
Subject: Re: Selecting random rows efficiently
In-Reply-To: <MKEGJINFADFODDNOKEJCGEGOEAAA.rg@tcslon.com>
References: <1062260304.669.566.camel@haggis> <MKEGJINFADFODDNOKEJCGEGOEAAA.rg@tcslon.com>
* 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