You are here: RE: [PHP] how to get time cost for MySQL query « PHP « IT news, forums, messages
RE: [PHP] how to get time cost for MySQL query

Posted by "yanghshiqi" on 07/12/05 20:32

Yes, mysql will cache your same query every time. So what you need is to
just test the microtime before and after your query script.
If you just want to know how about the efficiency about your sql script, you
can use the mysql_command line and explain it.
Otherwise, I think trying to catch the "query time" by mysql in php script
is useless as there are many other factors can affect you.




Best regards,
Shiqi Yang

-----Original Message-----
From: Ahmed Saad [mailto:myanywhere@gmail.com]
Sent: Tuesday, July 12, 2005 11:43 PM
To: php-general@lists.php.net
Subject: [PHP] how to get time cost for MySQL query

On 7/11/05, x <shamubro@gmail.com> wrote:
> Since we can see the time cost each time we query MySQL through MySQL
> console (such as 75 rows in set (0.01 sec)), so I am wondering there is
> already an existing function which will return the value...

I think you are confusing two things: mysql server and mysql
command-line client.
The time cost is calculated at the client side in mysql command-line
client. It's not retrieved from the server but rather calculated with
the help of three functions defined in mysql.cc: start_timer,
end_timer, mysql_end_time (all are internal functions that don't have
anything to do with the server). It's done more or less the way you
would normally do it in php: (1) take down current time (2) do the
query (3) take down time again and calculate the difference.

-ahmed

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация