[UPHPU] get count of database records matching criteria

Gary Thornock gthornock at yahoo.com
Sat Feb 26 10:37:31 MST 2005


--- Richard Miller <richardkmiller at gmail.com> wrote:
> Wade,
> 
> See
http://dev.mysql.com/doc/mysql/en/group-by-functions.html#id2928089.
> I think either of these would work:
> 
> SELECT COUNT(*) FROM <table> WHERE age >= 55;
> 
> or
> 
> SELECT COUNT(age) FROM <table> WHERE age >= 55;
> 
> I couldn't tell from the manual if there is any speed difference 
> between these two statements.

SELECT COUNT(age) will be a little faster (or a lot faster, if the
table is very large).  SELECT COUNT(1) may be even faster than that.


=====
PGP Key ID: 071B173D
Fingerprint: ED30 B048 6833 56B4 28C0 CE52 F12B 884A 071B 173D



More information about the UPHPU mailing list