Having the following queries, where the first query is returning a field of number of rows found, and the second returns the actual rows:
SELECT count(*) as total FROM individual i WHERE i.hid=:hhid AND i.hihh=:answer
$sql = "SELECT * FROM individual i WHERE i.hid=:hhid AND i.hihh=:answer"; $exec = $conn->prepare($checkHeadOfHH); $exec->bindValue(':hhid', $hhid); $exec->bindValue(':answer', $answer); $count=$exec->rowCount();
I want to know if the parser when a query contains
SELECT * FROM.. first then count the rows ? If yes, so basically, is better to use the second approach for better performance and less execution time ?
I am asking this question, because of having huge database and we always run
count(*) queries to check data.