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 "Richard Lynch" on 07/12/05 08:59

Try doing an "explain $query" query.

I *think* MySQL might cache the query/results enough that you'd get an
accurate estimate...

You could also turn MySQL Logging on.

Or, rather crudely, time it in PHP:

$query_start_time = microtime();
$result = mysql_query($query);
$query_end_time = microtime();

It's not going to be 100% accurate, of course, as the overhead from PHP to
MySQL is there, and if you get a *TON* of data in the query, then there's
maybe a LOT of overhead there...

But maybe you're better off including that anyway.

On Mon, July 11, 2005 10:23 am, x said:
> I did checked both of them and it seems they do not provide such info...
> thanks
> "Philip Hallstrom" <php@philip.pjkh.com> wrote in message
> news:20050711100227.W82043@wolf.pjkh.com...
>>> Hi, Is there any MySQL lib function which can provide time cost for
>>> last
>>> query?
>>>
>>
>> Maybe...
>>
>> http://us2.php.net/manual/en/function.mysql-info.php
>> http://us2.php.net/manual/en/function.mysql-stat.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Like Music?
http://l-i-e.com/artists.htm

 

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

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