Re: Selecting random rows efficiently

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: rj(at)last(dot)fm
Cc: PgSQL Performance ML <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Selecting random rows efficiently
Date: 2003-08-30 14:01:58
Message-ID: 1062252117.83670.29.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance

> 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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ron Johnson 2003-08-30 14:04:01 Re: Selecting random rows efficiently
Previous Message Bruce Momjian 2003-08-30 13:58:56 Re: SetVariable

Browse pgsql-performance by date

  From Date Subject
Next Message Ron Johnson 2003-08-30 14:04:01 Re: Selecting random rows efficiently
Previous Message Rod Taylor 2003-08-30 13:58:12 Re: Hardware recommendations to scale to silly load