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

From Russell Garrett
Subject Re: Selecting random rows efficiently
Date
Msg-id MKEGJINFADFODDNOKEJCGEGOEAAA.rg@tcslon.com
Whole thread Raw
In response to Re: Selecting random rows efficiently  (Ron Johnson <ron.l.johnson@cox.net>)
Responses Re: Selecting random rows efficiently
List pgsql-performance
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.



pgsql-performance by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: PostgreSQL HDD Grow capacity
Next
From: Rob Nagler
Date:
Subject: Re: How to force Nested Loop plan?