Re: Selecting random row

From: Doug McNaught <doug(at)wireboard(dot)com>
To: "Michal Taborsky" <michal(at)taborsky(dot)cz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Selecting random row
Date: 2002-08-02 16:20:06
Message-ID: m3d6t11bd5.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Michal Taborsky" <michal(at)taborsky(dot)cz> writes:

> This does decrease the the cost, but only very little (10500 -> 9800), which
> is not the solution. That thing with sequential index might work for some
> cases, that is true. Unfortunately not in this one, because I actually do
> not select random row from a table, but from a complex select query
> resultset. But thanks for the suggestions.

Why not

SELECT * FROM table LIMIT 1 OFFSET random(SELECT count(*) FROM TABLE);

I don't know if this is the exact syntax but you get the idea...

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Earl 2002-08-02 17:10:08 Re: Import from MS SQL Server?
Previous Message David Blood 2002-08-02 15:57:16 Re: [HACKERS] []performance issues