On Wed, Mar 19, 2008 at 10:35 AM, Nathan Nobbe <quickshiftin@xxxxxxxxx> wrote: > On Wed, Mar 19, 2008 at 9:42 AM, Andrew Ballard <aballard@xxxxxxxxx> > wrote: > > > That works; I'm just wondering why you went with a count on an 'ID' > > column > > rather than COUNT(*). > > > ouch, it looks like im horribly wrong :O > mysql> select count(*) from table; > +----------+ > | count(*) | > +----------+ > | 361724 | > +----------+ > 1 row in set (0.90 sec) > > mysql> select count(id) from table; > +------------+ > | count(did) | > +------------+ > | 361724 | > +------------+ > 1 row in set (4.56 sec) > > -nathan > I'm not sure, but I think that's because COUNT(*) simply counts the number of rows (which the query engine may be able to look up some other way than looping through all the rows) whereas COUNT(did) has to read each row to determine if there is a NULL value. I'm not sure if the engine can short-circuit this if it knows that the columns cannot be NULL, but then we are really headed to a database board rather than the PHP general list now. Andrew