Re: select where id=random()*something returns two results
| От | Ulrich Meis |
|---|---|
| Тема | Re: select where id=random()*something returns two results |
| Дата | |
| Msg-id | 000101c3803a$e05bffd0$9e318286@DAYWALK обсуждение исходный текст |
| Ответ на | Re: select where id=random()*something returns two results (Jean-Luc Lachance <jllachan@nsd.ca>) |
| Ответы |
Re: select where id=random()*something returns two results
|
| Список | pgsql-bugs |
> -----Original Message----- > From: pgsql-bugs-owner@postgresql.org [mailto:pgsql-bugs- > owner@postgresql.org] On Behalf Of Jean-Luc Lachance > Sent: Friday, September 19, 2003 4:44 PM > To: Rod Taylor > Cc: Ulrich Meis; pgsql-bugs@postgresql.org > Subject: Re: [BUGS] select where id=random()*something returns two results > > Rod, > > If the table has 100,000 tupples your query is generating 100,000 new > tupples... > Try: > > select * from quotes where id = ( > select int8( 1 + random() * ( > select id from quotes order by id desc limit 1))); > How about select * from quotes where id=1+int8((select random())*(select max(id) from quotes)); It works, but is it more or less efficient?
В списке pgsql-bugs по дате отправления: