Re: [PHP] Getting MySQL Query Times.
Use microtime before and after the query. $this-starttime=explode(' ',microtime()); // query() $this-endtime=explode(' ',microtime()); $this-starttime=$this-starttime[1]+$this-starttime[0]; $this-endtime=$this-endtime[1]+$this-endtime[0]; $this-parse_time=$this-endtime-$this-starttime; I've copied from working code of a class. But the idea is clear.This way is better than time() solutuion because with microtime() you get microseconds. But have in mind that on windows there are some problems with microtime() and the reported time can be negative. Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: Gabe da Silveira [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 7:22 PM Subject: [PHP] Getting MySQL Query Times. I was looking thru the mysql functions, and there doesn't seem to be one that gives you the amount of time a query takes. Is there anyway to get this information (since it gives it to you when you type queries directly into the mysql shell client)? A script of mine is starting to get fairly slow (2-3 seconds for page to process) and I want to be able to log the query speeds so I can see if there's a database bottleneck or if my code is just kludgy. -- __ Gabe da Silveira, Web Designer Twin Cities Student Unions University of Minnesota http://www.coffman.umn.edu wFone: (612)624-7270 eMail: [EMAIL PROTECTED] hPage: http://www.visi.com/~jiblet -- 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] Getting MySQL Query Times.
IMO, you are better off printing microtime [http://www.php.net/manual/en/function.microtime.php] before and after the query, and after you loop through it. This will give you a better idea of where the hangups may be. You may also want to sprinkle mircotimes throughout your code to get a good idea of processing time. Nathan Cook [EMAIL PROTECTED] - Original Message - From: Gabe da Silveira [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 10:22 AM Subject: [PHP] Getting MySQL Query Times. I was looking thru the mysql functions, and there doesn't seem to be one that gives you the amount of time a query takes. Is there anyway to get this information (since it gives it to you when you type queries directly into the mysql shell client)? A script of mine is starting to get fairly slow (2-3 seconds for page to process) and I want to be able to log the query speeds so I can see if there's a database bottleneck or if my code is just kludgy. -- __ Gabe da Silveira, Web Designer Twin Cities Student Unions University of Minnesota http://www.coffman.umn.edu wFone: (612)624-7270 eMail: [EMAIL PROTECTED] hPage: http://www.visi.com/~jiblet -- 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] Getting MySQL Query Times.
I was looking thru the mysql functions, and there doesn't seem to be one that gives you the amount of time a query takes. Is there anyway to get this information (since it gives it to you when you type queries directly into the mysql shell client)? A script of mine is starting to get fairly slow (2-3 seconds for page to process) and I want to be able to log the query speeds so I can see if there's a database bottleneck or if my code is just kludgy. I don't know if there's an actual function for it (although I wouldn't be surprised, knowing PHP :-), but you could definitely do something like: $start = mktime(); $sql = SELECT foo FROM bar ORDER BY xyzzy; $result = mysql_query ($sql); // do something with the result if you want that timed as well $end = mktime(); $total = $end - $start; echo $total; // could format this using date() if you fancy HTH Jon -- 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] Getting MySQL Query Times.
Thank you Andrey Nathan. THat was probably going to be the next thing to research. I think I figured out why my code got slow though. I have a preg search of a large field with .* in it at the beginning of an if,elseif,elseif,elseif struct that I should move to the end of it. In article 007601c12bf4$e0b41f40$[EMAIL PROTECTED], [EMAIL PROTECTED] (Nathan Cook) wrote: IMO, you are better off printing microtime [http://www.php.net/manual/en/function.microtime.php] before and after the query, and after you loop through it. This will give you a better idea of where the hangups may be. You may also want to sprinkle mircotimes throughout your code to get a good idea of processing time. In article 047c01c12bf3$bdae2b40$0b01a8c0@ANDreY, [EMAIL PROTECTED] (Andrey Hristov) wrote: Use microtime before and after the query. -- __ Gabe da Silveira, Web Designer Twin Cities Student Unions University of Minnesota http://www.coffman.umn.edu wFone: (612)624-7270 eMail: [EMAIL PROTECTED] hPage: http://www.visi.com/~jiblet -- 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] Getting MySQL Query Times.
$this-starttime=explode(' ',microtime()); // query. $this-endtime=explode(' ',microtime()); $this-starttime=$this-starttime[1]+$this-starttime[0]; $this-endtime=$this-endtime[1]+$this-endtime[0]; $this-parse_time=$this-endtime-$this-starttime; I've copied that from a class member but the idea is clear; Andrey Hristov IcyGEN Corporation http://www.icygen.com 99% - Original Message - From: Nathan Cook [EMAIL PROTECTED] To: [EMAIL PROTECTED]; Gabe da Silveira [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 7:57 PM Subject: Re: [PHP] Getting MySQL Query Times. IMO, you are better off printing microtime [http://www.php.net/manual/en/function.microtime.php] before and after the query, and after you loop through it. This will give you a better idea of where the hangups may be. You may also want to sprinkle mircotimes throughout your code to get a good idea of processing time. Nathan Cook [EMAIL PROTECTED] - Original Message - From: Gabe da Silveira [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, August 23, 2001 10:22 AM Subject: [PHP] Getting MySQL Query Times. I was looking thru the mysql functions, and there doesn't seem to be one that gives you the amount of time a query takes. Is there anyway to get this information (since it gives it to you when you type queries directly into the mysql shell client)? A script of mine is starting to get fairly slow (2-3 seconds for page to process) and I want to be able to log the query speeds so I can see if there's a database bottleneck or if my code is just kludgy. -- __ Gabe da Silveira, Web Designer Twin Cities Student Unions University of Minnesota http://www.coffman.umn.edu wFone: (612)624-7270 eMail: [EMAIL PROTECTED] hPage: http://www.visi.com/~jiblet -- 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] Getting MySQL Query Times.
On Fri, 24 Aug 2001 01:52, Gabe da Silveira wrote: I was looking thru the mysql functions, and there doesn't seem to be one that gives you the amount of time a query takes. Is there anyway to get this information (since it gives it to you when you type queries directly into the mysql shell client)? A script of mine is starting to get fairly slow (2-3 seconds for page to process) and I want to be able to log the query speeds so I can see if there's a database bottleneck or if my code is just kludgy. It might be worth running a mysql EXPLAIN on your query, if it is a complex one. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA Reality is an obstacle to hallucination. -- 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]