X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BBB62DAF56 for ; Sun, 27 Nov 2005 15:33:40 -0400 (AST) 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 15971-01 for ; Sun, 27 Nov 2005 15:33:39 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from avas-mr15.fibertel.com.ar (avas-mr15.fibertel.com.ar [24.232.0.247]) by svr1.postgresql.org (Postfix) with ESMTP id AD323DAEB9 for ; Sun, 27 Nov 2005 15:33:37 -0400 (AST) Received: from OL162-146.fibertel.com.ar ([24.232.146.162]:20229 "EHLO workstation" smtp-auth: "dculotta") by avas-mr15.fibertel.com.ar with ESMTPA id S1772332AbVK0Tdf; Sun, 27 Nov 2005 16:33:35 -0300 Message-ID: <003601c5f389$759a9020$6401a8c0@workstation> From: =?iso-8859-1?Q?Dami=E1n_Culotta?= To: "Cstdenis" , References: <000a01c5f2dc$a3bfa560$6501a8c0@chris> Subject: Re: Pagination of search results Date: Sun, 27 Nov 2005 16:33:35 -0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2670 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-Fib-Al-Info: Al X-Fib-Al-MRId: 31ab3523c666cd06c9eacd0845946f0f X-Fib-Al-From: dculotta@fibertel.com.ar X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.44 required=5 tests=[AWL=-0.479, DNS_FROM_RFC_ABUSE=0.479, DNS_FROM_RFC_POST=1.44] X-Spam-Score: 1.44 X-Spam-Level: * X-Archive-Number: 200511/29 X-Sequence-Number: 3346 If you sotre the count into a session, maybe you show incorrect information. It's possible that someone insert a new record when you are changing from one page to another. Sorry, my english it's very bad. ----- Original Message ----- From: "Cstdenis" To: "Neil Saunders" ; Sent: Saturday, November 26, 2005 5:59 AM Subject: Re: [PHP] Pagination of search results > Get the count once and store it in a session. > > ----- Original Message ----- > From: "Neil Saunders" > To: > Sent: Wednesday, November 23, 2005 8:14 AM > Subject: [PHP] Pagination of search results > > > Hi, > > I'm writing a search engine, the results of which will displayed in > blocks of 25, paginated. I will also display the number of records > found (1-25 of 345). > > I'm trying to determine the most efficient way to implement this. > Since the session is dropped after the script is terminated, I'm > ruling our cursors. Also, cursors would prevent me from retrieving the > total number of records potentially returned from a search, and so I > couldn't display the correct number of page links. Also, this would > require persistent connections, which I'd like to avoid for a number > of reasons. > > The best I've come up with is "SELECT b.*, c.cnt FROM table AS b, > (SELECT COUNT(1) AS cnt FROM table WHERE ) AS c WHERE > LIMIT 25 OFFSET 0" > > However this means that the query is essentially getting executed > twice for each page. > > Is there any better way of implementing this? All advice gratefully > received. > > Kind Regards, > > Neil Saunders. > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings > >