var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
which query is quickest?
which query is quickest.....
to count number of users in my database
do a mysql COUNT(id) on my table.
or select id, and do mysql_num_rows
which of those two will execute the fastest?
The first COUNT(id) will execute faster because no result set has to be transfered.
count(*) should be even faster - a well optimized DB backend will only count rows.
(Technically, the two are slightly different: count(id) only counts unique, non-null IDs - which shouldn't be an issue for a typical artificial primary key row, of course.)
Take it easy,
Look up the BENCHMARK() mysql command. This will help you.
only true for myisam.
Originally Posted by PPWH
for innodb, if i'm not wrong, the speed of select count(id) is almost the same as the speed of select id
thanks for the help guys