List:General Discussion« Previous MessageNext Message »
From:Ben Clewett Date:May 14 2008 11:39am
Subject:Re: Query execution time - MySQL
View as plain text  
If you using C++ then you can use this:

I use this in my code, does an excelent job.

Also you may want to look at the 'slow log' in mysql which will show, to 
the nearest second, the length of queries....


Neil Tompkins wrote:
> Hi Craig,
> Thanks for your detailed reply.  Basically what I'm trying to extract is the time
> taken from when I execute the mysql query in my C++ Builder program until the time the
> query has finished.
> So my question is can I build in to my SQL query SELECT Name FROM Customers the time
> the query actually took or do I need to do this outside of my query.
> Regards
> Neil
> Date: Wed, 14 May 2008 07:21:04 -0400From: craig.huffstetler@stripped:
> mysql@stripped: Re: Query execution time - MySQLCC:
> neildtompkins@stripped Niel,Not much detail there (but I'll go off what you
> provided...). Some people limit the actual MySQL system for times it TAKES MySQL to
> execute queries. For THIS to be accomplished, MySQL has built-in functionality to measure
> the time is takes queries to take place so it can ... limit them. So, in essence, I guess
> we can extract that data and get it back to you for whatever usage statistic you are
> looking to measure. ( See:
> ) or for usage in JDBC by calling the setQueryTimeout() function of a Statement
> object...and so forth.HOWEVER - Just so you know, if you execute the query MANUALLY via
> the command-line of MySQL it will tell you how long the query took. Just use normal SQL
> syntax, execute
 the query on the table and VOILA! Your answer:mysql queryormysqlrun the query (use the
below quoted/threaded example as a starting place to write your own query...?)Take a look
at this thread (it basically explains the answer with a bit more detail on what the output
will be):,51989,142404#msg-142404
> SELECT * FROM user_log; 15113 rows fetched in 5.3274s (0.1498s) SELECT
> BENCHMARK(100000000, RAND()); 1 row fetched in 0.0505s (13.2676s) I believe the results
> are the following: The first number is the time it took MySQL server to send the result
> set to the client. The second number (in parens) is the time it took MySQL server to
> execute the query itself.
> TOTAL TIME will EQUAL A + B (for total time it took on your server/P.C. or wherever
> you are running the query...). Many things come into factoring why it takes longer or
> shorter. So this is why I asked if you are attempting to optimize or what not, but that is
> whole new story. (( ----> What Operating System are you running? This would be helpful
> to give you the step-by-step, so to speak. Or perhaps provide us with a bit more
> information***Also, if you are looking to perhaps make it so queries take shorter times
> (optimization effort) to execute a little bit more about your MySQL database setup and
> machine(s) would be beneficial to us as well. ))Let me know if you have any
> questions.Standing by and I hope this helped you.Sincerely,Craig Huffstetlerxq on FreeNode
> #mysql | #apache
> On Wed, May 14, 2008 at 6:13 AM, Neil Tompkins <neildtompkins@stripped>
> wrote:
> Hi,When performing a SQL query like SELECT Name FROM Customers.  How do I obtain the
> time in which the query took to execute like 1.5 seconds
> etcThanks,Neil_________________________________________________________________All new
> Live Search at Live.com
> _________________________________________________________________
> Great deals on almost anything at Search, bid, find and win on eBay
> today!
Query execution time - MySQLNeil Tompkins14 May
  • Re: Query execution time - MySQLCraig Huffstetler14 May
    • RE: Query execution time - MySQLNeil Tompkins14 May
      • Re: Query execution time - MySQLBen Clewett14 May
Re: Query execution time - MySQLBen Clewett14 May
  • RE: Query execution time - MySQLNeil Tompkins14 May
  • RE: Query execution time - MySQLNeil Tompkins14 May
    • Re: Query execution time - MySQLEric Frazier14 May