flyhoney Posted June 1, 2006 Share Posted June 1, 2006 I am writing a search function for a website I have been building. I wanted to display the amoun of time a specific query took on the search page. Ive seen this done on other websites, is there a way to do this with mySQL? Link to comment https://forums.phpfreaks.com/topic/10930-getting-the-time-a-mysql-query-took/ Share on other sites More sharing options...
samshel Posted June 1, 2006 Share Posted June 1, 2006 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] Link to comment https://forums.phpfreaks.com/topic/10930-getting-the-time-a-mysql-query-took/#findComment-40832 Share on other sites More sharing options...
flyhoney Posted June 1, 2006 Author Share Posted June 1, 2006 I used the code you posted and it works great. I really appreciate it, makes my search even snazzier. Link to comment https://forums.phpfreaks.com/topic/10930-getting-the-time-a-mysql-query-took/#findComment-41052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.