What will be faster?

$i = $DB->query("SELECT COUNT(id) FROM `table`")->fetch_assoc(); 

or

 $i = $DB->query("SELECT id FROM `table`")->num_rows; 

?

  • 2
    Through SQL 100% will be faster - Dmitriy

1 answer 1

The first option will be faster because no need to waste time stuffing all the lines in response. RAM will not suffer again.