i have a problem here. this is my code
$res = mysqli_query($conn, "SELECT * FROM ( SELECT * FROM ( SELECT m.subnum, ma.cd 
FROM tr_mcerr AS m LEFT JOIN tr_mcerract AS ma ON m.subnum = ma.subnum 
order by ma.dtact DESC ) AS A GROUP BY A.subnum ) 
AS B WHERE B.cd = '01'") or die(mysqli_error($conn));
$totalRows_1 = mysqli_num_rows($res);
As you can see, i just want to get the number of rows. Now the problem is, this code alone take about around 2 seconds to complete. There are 5 more code like this but with different table and fields. so, just to get the page completely loaded would takes around 13 seconds to complete.
Is there another solution for this?
What are the reason that might causes the long execution time?
Thanks
SELECT count(*), so that's one part. Additionally, adding indexes to fields that are included inJOINstatements will dramatically help performance.Order byinside thesub-select. I don't see any use of it