If its a big hit, are you sure that you have the proper indexes on the table.

Another thing to consider is that if there is not a lot of activity on that table, you could place the total in a session object and revalidate that total every 10 queries or something to avoid querying the same table over and over.

Or use another table to hold the total number of entries in that table so that you are querying a small table without a lot of load on it. You could fill this table via a CRON or trigger (if available)


From: Zouari Fourat <[EMAIL PROTECTED]>
Reply-To: Zouari Fourat <[EMAIL PROTECTED]>
To: php-db@lists.php.net
Subject: [PHP-DB] Re: paginating : optimising queries
Date: Tue, 22 Mar 2005 17:02:57 +0100

no one can help me outta here ?

On Mon, 21 Mar 2005 01:58:10 +0100, Zouari Fourat <[EMAIL PROTECTED]> wrote: > Hello, > i made my own paginating class, it permit me to paginate over selected > data and let me do good presentation (page 1, page 2 ...) > i use adodb for db related functions, my application should show in > every page this set of informations : > > Total results : Z, Total page : Y, You are on the page number X. > > To show thos informations, i must do a count on all the table, example : > the query built from the form submitted by the user is : > > select * from table where column=value and column like 'value%' > > to paginate that query, i'll add some LIMIT or LIMIT OFFSET for pgsql > (it's adodb frontend) so i'll get only the data for one page ! > i use this query : > > select count(*) from table > > with that global count i can calculate how much pages i have by > dividing count on the number of rows to show per page. > > with this method, the server will suffer for big tables... > it's a method that i've made without consulting what people do, can > you do this with only ONE query so i can optimise ? > > thank you for your help >

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to