Jump to content

Getting the time a mySQL query took


flyhoney

Recommended Posts

As far as i remember Mysql doesnt provide you this data, but you can calculate it like this...

[code]
       list($usec, $sec) = explode(' ',microtime());
        $querytime_before = ((float)$usec + (float)$sec);

        $result   = mysql_query($query);

        list($usec, $sec) = explode(' ',microtime());
        $querytime_after = ((float)$usec + (float)$sec);

        $time_taken = $querytime_after - $querytime_before;

[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.