neoform Posted December 10, 2006 Share Posted December 10, 2006 Just wondering if there was a built-in function that would give me a given query's execution time..sort of like a mysql_ insert_ id() but for how long the query took.. I ask because i've noticed that when running queries from a command prompt, i can see the time it took, but i've never seen anything like that in php and using microtime() instead always gives me horribly inaccurate results.. Quote Link to comment https://forums.phpfreaks.com/topic/30125-mysql_query-execution-time/ Share on other sites More sharing options...
Zane Posted December 10, 2006 Share Posted December 10, 2006 there's no function for it but you could always do this$exTime = microtime();mysql_query("your query");echo "Query took " . microtime() - $exTime . " seconds"; Quote Link to comment https://forums.phpfreaks.com/topic/30125-mysql_query-execution-time/#findComment-138492 Share on other sites More sharing options...
neoform Posted December 10, 2006 Author Share Posted December 10, 2006 Hmmm, my only problem is that about 5% of the time i use microtime() i get negative values.....any ideas why that might happen? Quote Link to comment https://forums.phpfreaks.com/topic/30125-mysql_query-execution-time/#findComment-138611 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.