Re: mysql_num_rows speed
| From: | Zak McGregor | Date: | Fri, 09 Jun 2000 22:23:52 +0000 |
| Subject: | Re: mysql_num_rows speed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1475@lists.php.net to get a copy of this message | ||
On Fri, 9 Jun 2000 list@renaghan.com wrote:
> * David Norman <norny@geocities.com> [Jun 9 3:55pm]:
> > I'm counting some rows in mysql in a loop, so I want things to be as fast as
> > possible. Anyone know which is faster?
> >
> > $query = mysql_query("select count(*) from table where blah='blah'");
> > $thing = mysql_fetch_row($query);
> >
> > OR
> >
> > $query = mysql_query("select column from table where blah='blah'");
> > $thing = mysql_num_rows($query);
> >
> > I'm thinking the first is, but it's nice to have a second opinion :)
>
> Without doing any testing, I would have to say that the first
> solution is faster. Less work for the database, and less data
> returned over the wire.
Your faster option is probably
$query = mysql_query("select count(column) from table where blah='blah'");
$thing = mysql_fetch_row($query);
Ciao
====================================================================
Zak McGregor
http://www.zap.co.za/zgas - On-line specifications of over
6700 cars
====================================================================