Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D171C632E08 for ; Thu, 19 Nov 2009 02:48:11 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 94374-06 for ; Thu, 19 Nov 2009 06:48:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd-17937.dedibox.fr (sd-17937.dedibox.fr [88.191.100.74]) by mail.postgresql.org (Postfix) with ESMTP id AF3CE632C49 for ; Thu, 19 Nov 2009 02:48:03 -0400 (AST) Received: from laptop.localnet (LCaen-151-93-7-26.w80-13.abo.wanadoo.fr [80.13.230.26]) by sd-17937.dedibox.fr (Postfix) with ESMTPA id 398003B8EE; Thu, 19 Nov 2009 07:48:02 +0100 (CET) From: Guillaume Lelarge To: pgsql-sql@postgresql.org Subject: Re: LIMIT BASED ON PERCENT Date: Thu, 19 Nov 2009 07:47:59 +0100 User-Agent: KMail/1.12.2 (Linux/2.6.31-14-generic; KDE/4.3.2; i686; ; ) Cc: Kris Kewley , Another Trad , Lee Hachadoorian References: <200911182027.08857.guillaume@lelarge.info> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200911190748.00451.guillaume@lelarge.info> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.956 tagged_above=-10 required=5 tests=BAYES_00=-2.599, RCVD_IN_NJABL_PROXY=1.643 X-Spam-Level: X-Archive-Number: 200911/59 X-Sequence-Number: 33410 Le jeudi 19 novembre 2009 =E0 01:20:24, Kris Kewley a =E9crit : > Could you not create a function to do this instead? >=20 > Set var_limit =3D 20% of row count > Replace subquery with var_limit >=20 Sure, see the previous mails from Pavel. You can also put the percent as a= =20 parameter of the function. =2D-=20 Guillaume. http://www.postgresqlfr.org http://dalibo.com