Re: Selecting random rows efficiently
От | Russell Garrett |
---|---|
Тема | Re: Selecting random rows efficiently |
Дата | |
Msg-id | MKEGJINFADFODDNOKEJCGEGOEAAA.rg@tcslon.com обсуждение исходный текст |
Ответ на | Re: Selecting random rows efficiently (Ron Johnson <ron.l.johnson@cox.net>) |
Ответы |
Re: Selecting random rows efficiently
|
Список | 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 по дате отправления: