Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9BKZ1n00133 for ; Thu, 11 Oct 2001 16:35:01 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f9BKRkW89714 for pgsql-sql@postgresql.org; Thu, 11 Oct 2001 16:27:46 -0400 (EDT) (envelope-from news) From: Orion X-Newsgroups: comp.databases.postgresql.sql Subject: count(*) and limit Date: Thu, 11 Oct 2001 13:31:59 -0700 Organization: TrustCommerce Lines: 21 Message-ID: <9q4vc1$2nej$1@news.tht.net> Reply-To: o2@trustcommerce.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: scrappy@hub.org User-Agent: KNode/0.6.1 To: pgsql-sql@postgresql.org X-Archive-Number: 200110/180 X-Sequence-Number: 5135 I have a interface where users are paging through results of a query. In order to do so I need to select count(*) from data where stuff; To find out how many pages of data there are ( needed for the navigation bar) and then I need to select * from data where stuff limit X offset y; Now, postgres has to get the whole result before running the limit. Is there some trick to get how many rows there would be without the limit so I dont need to run the extra count(*) query? It seems like a waste. Orion