Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 253016329B9 for ; Wed, 18 Nov 2009 15:34:07 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 41132-04 for ; Wed, 18 Nov 2009 19:33:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yx0-f181.google.com (mail-yx0-f181.google.com [209.85.210.181]) by mail.postgresql.org (Postfix) with ESMTP id 540B36359F6 for ; Wed, 18 Nov 2009 15:33:56 -0400 (AST) Received: by yxe11 with SMTP id 11so1287605yxe.15 for ; Wed, 18 Nov 2009 11:33:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=RTLDd5+ZXI42+ydkSTFeymSJ6ezqyBBJlFrYs0Yy0TY=; b=stccNAOP99OsX8T2qe2SbSiJRVj3CKZ8p77FErgj5UcQfX9Z/TZKegrO6MyWnB4aMV pw8c+owZKf/N89pYtL4XAurjXvug0RBcoFQFlW7ye8x14JbrC6eDISglveFiUARGlomb watJUp1J3acBi2S2XdoD1d54PKJDq5RsNtdaU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=A99seiW0KsivQTgSBB2f7rbgkR9pqnGErVieJO1I32lfUNQwTC85o030ePJajj7zxv uB7cl2H/Eix64wXH7pJC3fdJKPyC0yWivzIuTo5XtU1B/092JFrBPgYuPyqv20yzPgtb OFI8qCLe2wPiTgiuflDTKFQhvZiR8bNttm1Dg= MIME-Version: 1.0 Received: by 10.91.55.28 with SMTP id h28mr2648750agk.36.1258572833485; Wed, 18 Nov 2009 11:33:53 -0800 (PST) In-Reply-To: <162867790911181130n74be837eo29e3c408724c88f7@mail.gmail.com> References: <5ab13580911181121g6e89759doa6c6ea6557424f71@mail.gmail.com> <200911182027.08857.guillaume@lelarge.info> <162867790911181130n74be837eo29e3c408724c88f7@mail.gmail.com> Date: Wed, 18 Nov 2009 14:33:53 -0500 Message-ID: <5ab13580911181133k6204bbb0h33a695e618bfa02b@mail.gmail.com> Subject: Re: LIMIT BASED ON PERCENT From: Lee Hachadoorian To: Pavel Stehule Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.996 tagged_above=-10 required=5 tests=AWL=0.604, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/55 X-Sequence-Number: 33406 On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule 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.