RE: [PHP] SQL Query time?
I wonder if using microtime() gives _actual_ time spent for the query while explain gives _processor_ time. Anuradha On Thu, 26 Apr 2001, Maxim Maletsky wrote: what about microtime() ? you can do it your self: $start = microtime(); mysql_query()... $stop = microtime(); $token = round($stop-$start, 3); echo Query took $token seconds; I mean this is not as precise as SQL would do itself, but will work approximately. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: James, Yz [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 26, 2001 5:17 AM To: [EMAIL PROTECTED] Subject: [PHP] SQL Query time? Hi all, I have seen a few pages that echo the time it's taken to execute an SQL query, like The results in the database were returned in 0.3 seconds. Anyone know if there's a built in function to display this, and if there is, what it is? My more-than-useless-ISP seems to have taken an aversion to allowing me to surf tonight without disconnecting me. Thanks. James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query time?
On Mié 25 Abr 2001 23:17, James, Yz wrote: Hi all, I have seen a few pages that echo the time it's taken to execute an SQL query, like The results in the database were returned in 0.3 seconds. Anyone know if there's a built in function to display this, and if there is, what it is? My more-than-useless-ISP seems to have taken an aversion to allowing me to surf tonight without disconnecting me. That depends on the SQL server you are using (and I'm not talking about M$SQL Server! :-) ). In postgreSQL you do that with an EXPLAIN query, but the results are given throught the warning output, and there is no function to grab it. But it wouldn't be difficult to build it. :-) Saludos... :-) -- El mejor sistema operativo es aquel que te da de comer. Cuida tu dieta. - Martin Marques |[EMAIL PROTECTED] Programador, Administrador | Centro de Telematica Universidad Nacional del Litoral - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] SQL Query time?
Sup, Adding explain before the select query will show you how long it will take, along with some other info, but it won't actually give you the results. I use a the function microtime (http://php.net/microtime) to figure execution time. When called, microtime will return a string with miliiseconds then seconds seperated by a space. So you have to do something like this... function sn_Msecs() { $mt = microtime(); $mt = explode( , $mt); return ($mt[1] + $mt[0]); } That will return seconds.milliseconds or something like 13123141.1231, it is not in proper math form. Just call it before a block of code or query, then call it after and subtract the second one from the first. SL. - Original Message - From: James, Yz [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, April 25, 2001 2:17 PM Subject: [PHP] SQL Query time? Hi all, I have seen a few pages that echo the time it's taken to execute an SQL query, like The results in the database were returned in 0.3 seconds. Anyone know if there's a built in function to display this, and if there is, what it is? My more-than-useless-ISP seems to have taken an aversion to allowing me to surf tonight without disconnecting me. Thanks. James. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]