Re: Best way to return Random rows from a table with non-repeatability of rows

From: Kiran <bangalore(dot)kiran(at)gmail(dot)com>
To: Chris Mair <chris(at)1006(dot)org>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best way to return Random rows from a table with non-repeatability of rows
Date: 2016-10-29 20:35:44
Message-ID: CAJfd1U6++QOxBzp=2v8XviuvR9k3LcL1P8cKP8_L8_dQmHexyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Chris,

Thank you very much. Will look into examples and syntax.

regards
Kiran

On Sat, Oct 29, 2016 at 3:18 PM, Chris Mair <chris(at)1006(dot)org> wrote:

> Dear folks,
>>
>> I have a table with thousands of rows ( currently 15 thousand but will
>> grow very fast).
>> I need to return from the query rows which are random and non-repeating.
>> I know there is random() function, but would like to know from
>> postgresql practitioners before embarking that path.
>> Please let me know what is best way to handle this type of queries.
>>
>> regards
>> Kiran
>>
>
> Hi,
>
> if you're using Postgres >= 9.5 what you are looking for is TABLESAMPLE.
>
> Syntax is here:
> https://www.postgresql.org/docs/9.5/static/sql-select.html
>
> Google tablesample+postgres to get some examples on how to use it.
>
> Bye,
> Chris.
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-10-29 21:15:31 Re: Cannot access the return value of a PostgreSQL function using ADO
Previous Message Rich Shepard 2016-10-29 17:06:27 Re: E-R diagram code U1