Received: from mta2.snet.net (mta2.snet.net [204.60.203.71]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0GFToV16901 for ; Wed, 16 Jan 2002 10:29:50 -0500 (EST) (envelope-from wweng@kencast.com) Received: from pop.snet.net ([204.60.203.73]) by mta2.snet.net (8.12.1/8.12.1/SNET-smtp-1.1/D-1.1/O-1.1) with ESMTP id g0GFTsBB014661; Wed, 16 Jan 2002 10:29:54 -0500 (EST) Received: from Monet (167.95.252.64.snet.net [64.252.95.167]) by pop.snet.net (8.12.1/8.12.1/SNET-pop-1.2/D-1.2/O-1.3) with SMTP id g0GFTj2T008244; Wed, 16 Jan 2002 10:29:46 -0500 (EST) Date: Wed, 16 Jan 2002 10:36:54 -0500 From: Wei Weng To: "Koen Antonissen" Cc: pgsql-sql@postgresql.org Subject: Re: Count Total on a limited query? Message-Id: <20020116103654.0c47424a.wweng@kencast.com> In-Reply-To: References: Organization: KenCast Inc. X-Mailer: Sylpheed version 0.6.6 (GTK+ 1.2.10; i586-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200201/185 X-Sequence-Number: 6271 I don't think an extra count query is that much of a work to the system. A counting on the indexed column is very fast. On Wed, 16 Jan 2002 13:55:18 +0100 "Koen Antonissen" wrote: > Hi group, > > I've implemented a couple of search queries, to prevent too many results > transferring/getting displayed I use a LIMIT. Now I would like to > display the total numbers found on the query (discarding the limit). > > Is this possible in a nice manner? > I thought up the following: > 1. Implementing the limit system in PHP > Con: Too much work for something this elementary > 2. Executing an extra search query which only counts > Con: An extra query which feels unnecessary > 3. Using a subselect which only counts > Con: although it gives a nice result, and isn't much work, the query > will be executed for each record and therefore not an option. > > > I hope this can be done using PostgreSQL. > > Thank you, > Koen Antonissen > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > -- Wei Weng Network Software Engineer KenCast Inc.