Re: Performance - WAS: Problem with count(*) in db query

From: Date: Mon, 08 Nov 2004 11:30:30 +0000
Subject: Re: Performance - WAS: Problem with count(*) in db query
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15384@lists.php.net to get a copy of this message
George Pitcher wrote:
My test searches a 3,100+ record table, grabs university-level data (university courses) then does 7 queries on a 32,000+ record transaction table to produce some stats. Then, while displaying each row in a table, does 5 queries on related records in the transaction table.
If you display let's say 10 000 rows, doing 5 additional query per row, that is 50 000 queries in 24 secs = 2083 queries / sec. I wouldn't say it is slow. The thing that slows down your app is the number of queries. As I wrote in my previous mail, try to reduce them if possible by a) using subselects/views/sps if possible, b) rephrase your code to "emulate" subselects (e.g. collect id's of the records to display into an array, implode() the array to a string, pass it to your query like: select * from sometable where id in (1, 2, ..., 10496) instead of: select * from sometable where id = 1 select * from sometable where id = 2 .. select * from sometable where id = 10496 Hope this helps. Regards, Norbert

« previous php.pear.general (#15384) next »