But the first query isn't correct. It looks as if half has been cut away. Consider
id mday_no
1 2
1 20
2 28
Which would turn
"SELECT * FROM cb_main WHERE mid = '$the_id' AND mday_no=(select max(mday_no)";
into
"SELECT * FROM cb_main WHERE mid = '$the_id' AND mday_no=28";
=> no results found
You lack the mid comparison in the nested query.
$sql_main = "SELECT * FROM cb_main WHERE mid = '$the_id' AND mday_no=(select max(mday_no) FROM cb_main WHERE mid = '$the_id')";
Which make me belive the use of subquery runs in O(m n), where n is the number of records in the table (for the subquery) and m is the number of records with mid = $the_id.
And I doubt the ORDER BY query taking O(n log n). It should not need to sort the whole table first. And since the limit 1 is there, the sorting on the set of size m should stop once the first 1 records have been "sorted".
But it never hurts to see if belief is fact.
$sql1 = '...';
$sql 2 = '...';
$start1 = microtime(true);
mysql_query($sql1);
$end1 = microtime(true);
$start2 = microtime(true);
mysql_query($sql2);
$end2 = microtime(true);
$diff1 = $end1 - $start1;
$diff2 = $end2 - $start2;