On Fri, Jun 20, 2008 at 2:46 PM, demon@svn.wikimedia.org wrote:
No need to count(*) in SiteStats::admins ...
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(ug_group)', array( 'ug_group' => 'sysop' ), __METHOD__ );
What is this intended to do? ug_group is NOT NULL; COUNT(ug_group) will always be identical to COUNT(*).
Simetrical wrote:
On Fri, Jun 20, 2008 at 2:46 PM, demon@svn.wikimedia.org wrote:
No need to count(*) in SiteStats::admins ...
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(ug_group)', array( 'ug_group' => 'sysop' ), __METHOD__ );
What is this intended to do? ug_group is NOT NULL; COUNT(ug_group) will always be identical to COUNT(*).
There's a myth going around that COUNT(*) means: load all data in the row into memory, throw it away, and then add one to some counter. It doesn't. Benchmarking has confirmed that COUNT(*) is as fast as COUNT(some_index).
-- Tim Starling
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Simetrical wrote:
On Fri, Jun 20, 2008 at 2:46 PM, demon@svn.wikimedia.org wrote:
No need to count(*) in SiteStats::admins ...
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(ug_group)', array( 'ug_group' => 'sysop' ), __METHOD__ );
What is this intended to do? ug_group is NOT NULL; COUNT(ug_group) will always be identical to COUNT(*).
There is an urban legend that count(field) is faster than count(*), since it doesn't have to load all those fields specified by the '*'. I'm pretty sure it's not actually true, though, and that the database knows that '*' just means "count the rows" here. :)
- -- brion
On Fri, Jun 20, 2008 at 7:26 PM, Brion Vibber brion@wikimedia.org wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Simetrical wrote:
On Fri, Jun 20, 2008 at 2:46 PM, demon@svn.wikimedia.org wrote:
No need to count(*) in SiteStats::admins ...
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(*)', array( 'ug_group' => 'sysop' ), __METHOD__ );
self::$admins = $dbr->selectField( 'user_groups', 'COUNT(ug_group)', array( 'ug_group' => 'sysop' ), __METHOD__ );
What is this intended to do? ug_group is NOT NULL; COUNT(ug_group) will always be identical to COUNT(*).
There is an urban legend that count(field) is faster than count(*), since it doesn't have to load all those fields specified by the '*'. I'm pretty sure it's not actually true, though, and that the database knows that '*' just means "count the rows" here. :)
- -- brion
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkhcPLwACgkQwRnhpk1wk47T7QCeIXzYsnuOq6dP6IGNdMWIdUf5 I+8Anj01N3RGsCgEfKevh+ZiGVnM2rpz =phbF -----END PGP SIGNATURE-----
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Count me in the list of people who were fooled by the rumors then.
-Chad
On Fri, Jun 20, 2008 at 7:26 PM, Brion Vibber brion@wikimedia.org wrote:
There is an urban legend that count(field) is faster than count(*), since it doesn't have to load all those fields specified by the '*'. I'm pretty sure it's not actually true, though, and that the database knows that '*' just means "count the rows" here. :)
In fact, Peter Zaitsev seems to find that COUNT(field) can be significantly slower, because while MySQL is smart enough to pick any unique NOT NULL index for COUNT(*), it can't always figure out that it can do the same for COUNT(field):
http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/
wikitech-l@lists.wikimedia.org