pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Lee Hachadoorian <lee.hachadoorian@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: LIMIT BASED ON PERCENT
Date: Wed, 18 Nov 2009 20:39:34 +0100
Message-ID: <162867790911181139s38dd9ae4n7b1474523d3f2c3b@mail.gmail.com> (raw)
In-Reply-To: <5ab13580911181133k6204bbb0h33a695e618bfa02b@mail.gmail.com>
References: <af7271950911181112h574da17euf94d9640ec7680df@mail.gmail.com>
	<5ab13580911181121g6e89759doa6c6ea6557424f71@mail.gmail.com>
	<af7271950911181124i2a309729q2271d9f878e42f3d@mail.gmail.com>
	<200911182027.08857.guillaume@lelarge.info>
	<162867790911181130n74be837eo29e3c408724c88f7@mail.gmail.com>
	<5ab13580911181133k6204bbb0h33a695e618bfa02b@mail.gmail.com>

2009/11/18 Lee Hachadoorian <lee.hachadoorian@gmail.com>:
> On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>> yes, and don't use 20%.
>>
>> select * from foo order by somecol limit (select (count(*)*0.2)::int from foo)
>>
>> Regards
>> Pavel
>
> Is this faster on a large table? Because (select (count(*)*20/100)) worked fine.
>

this is +/- same - 20/100 is maybe about 0.000001% faster - you don't
need one float to query cast, but this operation is only one pqr
query. The problem is two  full scan of table.

Pavel



view thread (11+ messages)  latest in thread

Message-ID: <162867790911181139s38dd9ae4n7b1474523d3f2c3b@mail.gmail.com>
Permalink:  ../162867790911181139s38dd9ae4n7b1474523d3f2c3b@mail.gmail.com/
Also on:    postgresql.org/message-id/162867790911181139s38dd9ae4n7b1474523d3f2c3b@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pavel.stehule@gmail.com, lee.hachadoorian@gmail.com
  Subject: Re: LIMIT BASED ON PERCENT
  In-Reply-To: <162867790911181139s38dd9ae4n7b1474523d3f2c3b@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox