You are here: explain select « PHP « IT news, forums, messages
explain select

Posted by Carl Furst on 07/12/05 21:06

Explain select will only explain how mysql is going to use different
keys and indexes to optimize query not actually give you a time
estimate. The actual time it takes to handle indexes and such,
especially if you are using joins, has to do with the Key_buffer and
join_buffer values in your my.cnf or my.ini. If you raise these
values then it might be faster because there will need to be less
disk seeks when doing querry. The speed of a database depends on how
much disk accessing need be done on any querry, as I'm sure you know.

So check these values if you really need to speed up queries that use
a lot of indexes to generate your results.

C.

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-sta

Carl Furst
cfurst@intracommunities.org

 

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

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