Performance - WAS: Problem with count(*) in db query
| From: | George Pitcher | Date: | Mon, 08 Nov 2004 10:43:13 +0000 |
| Subject: | Performance - WAS: Problem with count(*) in db query | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15382@lists.php.net to get a copy of this message | ||
Thanks $db->getOne() worked.
However my page is pretty slow.
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.
The sample page shows 4 courses for the university and takes 24 seconds to
display.
Everything in my tables is indexed.
Any tips on how to improve performance?
Cheers
George
> -----Original Message-----
> From: Sönke Ruempler [mailto:ruempler@topconcepts.de]
> Sent: 8 November 2004 9:36 am
> To: George Pitcher; Pear
> Subject: RE: [PEAR] Problem with count(*) in db query
>
>
> George Pitcher wrote on Monday, November 08, 2004 10:15 AM:
>
> > $tranSQL = "select count(*) from transactions where (course_id =
> > 20867 and hei_action ='')";
> > $tr_r = $db->query ($tranSQL);
> > while ($row = $tr_r->fetchRows()){
> > $tr_count = $row[0];
> > }
> >
> > and if I try that query directly onto the database I get '1'
> > in a single
> > cell named 'count(*)'.
>
> try $db->getOne()
>
>
> http://pear.php.net/manual/en/package.database.db.db-common.getone.php
>
> > but my pear query produces an error:
> > "PHP Fatal error: Call to undefined method DB_result::fetchRows() in
> > C:\Inetpub\wwwroot\Egret\Activepacklist.php on line 163"
>
> it's fetchRow()
>
>
> http://pear.php.net/manual/en/package.database.db.db-result.fetchrow.php
>
> but obviously not what you want here (use getOne).
>