On Fri, Jun 20, 2008 at 2:46 PM,
<demon(a)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