What is the difference between these two methods?
select count(*) from `table` where `column` = 'value';
and
select count(`column` = 'value') from `table`;
To me they seem to do the same thing; I assume this is not the case for the database. Does one method leverage indexes better than the other?
In this case I use MySQL but a general answer is preferred here.
count(
column= ‘value’)Would generally seem to imply you are counting the boolean result of the comparison, which should count all the rows in the table, though perhaps your particular DBMS has an exception.
Filter the query on the where clause. It will be a good habit in case you ever need to write a similar query for a different database.