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? Quote 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] Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.