Re: Optimizing DISTINCT with LIMIT

From: Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl>
To: David Lee Lambert <davidl(at)lmert(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Optimizing DISTINCT with LIMIT
Date: 2008-12-06 18:08:56
Message-ID: 1E3782D0-1A9D-4C28-A307-F06E767312AA@pointblue.com.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2008-12-06, at 11:29, David Lee Lambert wrote:
>>
>
> I use "ORDER BY random() LIMIT :some_small_number" frequently to get
> a "feel"
> for data. That always builds the unrandomized relation and then
> sorts it. I
> guess an alternate path for single-table queries would be to
> randomly choose
> a block number and then a tuple number; but that would be biased
> toward long
> rows (of which fewer can appear in a block).

but that's going to be extremely slow, due to speed of random()
function.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2008-12-06 18:19:05 benchmarking the query planner (was Re: Simple postgresql.conf wizard)
Previous Message Martin Pihlak 2008-12-06 17:34:49 Re: SQL/MED compatible connection manager