> > > > I have got some expensive sql queries (doing lots of LEFT JOINS) that result > > in anything between 10 to 10000 results. I need to do paging on those. So > > far I have used a LIMIT solution which will not do anymore because you don't > > get the whole total. i just decided to issue a count query, then use limit as the following $count_query = "select count(*) as dict_pager_search from ".$def_table ." where word like '" . $search . "%' "; // not much worse than an extra count query $countResult = sql_fetch($count_query); $max_from_db_table = $countResult[dict_pager_search]; ...<snip> then use logic to find the slice you want and create the logic my logic was copied from DB::Pager module then make a limit query as shown here (DB::Pager computes offsets for me given size, which came from the count query above) if ($debug_dict_pager) echo "------------- page offsets ---------------<br>"; $max_minArr = $pager->getOffsetByPageId(); if ($debug_dict_pager) var_dump($max_minArr); if ($debug_dict_pager) echo "<br>"; $offset = $max_minArr[0] -1; // if it returns 1, the sql query 'offset 1' skips the first row $upper_limit = $max_minArr[1]; $sql_limit = $upper_limit - $offset; if ($debug_dict_pager) echo "offset = $offset<br>"; if ($debug_dict_pager) echo "limit = ". $sql_limit . "<br>"; i am ignorant as to why anybody would need 10,000 results at one time. maybe instead of decreasing the left joins you should combine them into a query which makes for a smaller result set. MAYBE. well, you will only deal with sql_server load not apache_server also using cpu. i also am looking at server-side sql solutions now. > > The question now is: is the serializing/unserializing more expensive than > > another db call? > yes, file connection/db connection are same speed, in milliseconds, as compared to CPU time which is nanoseconds. but you have already a connection to the DB, just use it is inexpensive. does php let you use shared memory to store the sessions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php