From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | nikolay(at)samokhvalov(dot)com |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: mal advice in FAQ 4.1. |
Date: | 2007-10-09 13:05:13 |
Message-ID: | 162867790710090605o312195e0h6dde0d00cb939c24@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2007/10/9, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>:
> Hubert recently posted his thoughts on this topic:
> http://www.depesz.com/index.php/2007/09/16/my-thoughts-on-getting-random-row/
>
> I've encountered with this problem several times in web development and
> every time found out that the best (in terms of performance) solution is to
> use some pseudo random approach (such as ">= random() limit 1" or "limit 1
> offset random()*N" or even pre-caching rows on app side).
>
I know this article, but you cannot link from faq to private
(unstable) blog. it would article on techdoc.postgresql.org
Pavel
On 10/9/07, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> > Hello
> >
> > I found lot of slow queries in some databases which I checked based on
> > advice 4.1. from FAQ,
> >
> > To SELECT a random row, use:
> > SELECT col
> > FROM tab
> > ORDER BY random()
> > LIMIT 1;
> >
> > It's robust and slow on bigger tables. Can we add some better solutions?
> >
>
>
> --
> Best regards,
> Nikolay
From | Date | Subject | |
---|---|---|---|
Next Message | Hiroshi Saito | 2007-10-09 13:19:42 | permission denied for tablespace pg_global? |
Previous Message | Nikolay Samokhvalov | 2007-10-09 12:52:30 | Re: mal advice in FAQ 4.1. |