Jump to content


Photo

get the number of seconds to execute a query


  • Please log in to reply
4 replies to this topic

#1 n8w

n8w
  • Members
  • PipPipPip
  • Advanced Member
  • 123 posts

Posted 01 April 2006 - 08:17 PM

I'm trying to improve performance on my database.

How do I get the time it took to execute a query

you know something like

searched 10000 records in .025 seconds ..

thanks
n8w

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 02 April 2006 - 12:52 AM

Usually you do it in your application. If you are using PHP, you can do something like this:

$start = microtime(TRUE);
$result = mysql_query($query);
$querytime = microtime(TRUE) - $start;


#3 n8w

n8w
  • Members
  • PipPipPip
  • Advanced Member
  • 123 posts

Posted 02 April 2006 - 03:40 AM

thanks so much! ..

I have some interesting results.. do you know why I get a negative number on

[a href=\"http://www.illustrationmundo.com/illustrators.php\" target=\"_blank\"]http://www.illustrationmundo.com/illustrators.php[/a]

but a positive number on

[a href=\"http://www.illustrationmundo.com/news.php\" target=\"_blank\"]http://www.illustrationmundo.com/news.php[/a]

you can see the result time on the bottom left hand corner of the page

#4 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 02 April 2006 - 04:51 AM

Hard to say without seeing what you did. Make sure you use microtime(TRUE) and not just microtime(), as the latter will not be correct.

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 02 April 2006 - 09:57 PM

You can access what you see on the command-line return, but only via the C API functions; you might as well profile it in middleware.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users