Re: SELECT TOP %d PERCENT, or SELECT ... LIMIT %d PERCENT ?

From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: "Grzegorz Jaskiewicz" <gj(at)pointblue(dot)com(dot)pl>
Cc: "Hitoshi Harada" <umi(dot)tanuki(at)gmail(dot)com>, "Pg Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SELECT TOP %d PERCENT, or SELECT ... LIMIT %d PERCENT ?
Date: 2008-10-12 13:46:11
Message-ID: 603c8f070810120646i7fbe3f24x295516476ca41f1f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wonder if this could be implemented using the window-function
infrastructure...

...Robert

On Sun, Oct 12, 2008 at 9:07 AM, Grzegorz Jaskiewicz
<gj(at)pointblue(dot)com(dot)pl> wrote:
> that's a shame.
> I figure, with the "WITH ... AS .." you can kind of speed up counts, just by
> doing it once - now. But still, it would be great to be able to use PERCENT,
> against estimate.
> After all, imagine a table FOO with 5 rows, and something like this:
>
> WITH c AS (select count(*)/4 as n from FOO) select * from FOO limit (select
> n from c) offset (select n*X from c);
>
> now X is for every 25%, but you wan't get to see last row if you use offset
> 75 percent (X=3). Which kind of puts me off the idea of using PERCENT
> anyway, because it isn't quite accurate.
>
> So thanks for answer, I'll pass on this one. Hopefully there would be
> another chance for me to write some patch in future.
>
> ta.
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2008-10-12 14:41:21 Re: The Axe list
Previous Message Zdenek Kotala 2008-10-12 13:32:46 [PATCH] Extending pg_class info + more flexible TOAST chunk size