X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0E4785381E for ; Fri, 8 Apr 2005 22:38:04 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50969-06 for ; Fri, 8 Apr 2005 21:37:57 +0000 (GMT) Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) by svr1.postgresql.org (Postfix) with ESMTP id AB9C75384A for ; Fri, 8 Apr 2005 22:37:55 +0100 (BST) Received: (qmail 28216 invoked from network); 8 Apr 2005 23:38:19 +0200 Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) by boutiquenumerique.com with SMTP; 8 Apr 2005 23:38:19 +0200 To: "Joel Fradkin" , "'Tom Lane'" , "'Bob Henkel'" Cc: "'Scott Marlowe'" , "'Andrew Sullivan'" , pgsql-sql@postgresql.org Subject: Re: getting count for a specific querry References: <004b01c53c72$5e4c6390$797ba8c0@jfradkin> Message-ID: Date: Fri, 08 Apr 2005 23:37:55 +0200 From: PFC Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In-Reply-To: <004b01c53c72$5e4c6390$797ba8c0@jfradkin> User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/129 X-Sequence-Number: 21022 > Since it is a count of matched condition records I may not have a way > around. What you could do is cache the search results (just caching the id's of the rows to display is enough and uses little space) in a cache table, numbering them with your sort order using a temporary sequence, so that you can : SELECT ... FROM cache WHERE row_position BETWEEN page_no*per_page AND (page_no+1)*per_page-1 to get the count : SELECT row_position FROM CACHE ORDER BY row_position DESC LIMIT 1 Add a session_id referencing your sessions table with an ON DELETE CASCADE and the cache will be auto-purged when sessions expire.