Neil Tompkins wrote:
Thanks for your help.  In the end I've decided to use GetTickCount()
Neil



Date: Wed, 14 May 2008 13:44:22 +0100> From: [EMAIL PROTECTED]> To: [EMAIL PROTECTED]> CC: mysql@lists.mysql.com> Subject: Re: Query execution time - MySQL> > Hi Neil,> > If your using Linux then you have to install the glib RPM's 
in the usual > way. I don't know about other platforms, but I am sure there will be a > version of glib out there...> > Also ensure the correct include and link directives are in your > Makefile, which you can get (on Linux) using the 
commands:> > # glib-config --cflags> # glib-config --libs> > Ben> > Neil Tompkins wrote:> > Thanks Ben, but I don't appear to have the header file <glib.h> in my > > libraries.> > > > Neil> > > 
> > > ------------------------------------------------------------------------> > > > > Date: Wed, 14 May 2008 12:39:09 +0100> > > From: [EMAIL PROTECTED]> > > To: [EMAIL PROTECTED]> > > CC: [EMAIL 
PROTECTED]; mysql@lists.mysql.com> > > Subject: Re: Query execution time - MySQL> > >> > > If you us
ing C++ then you can use this:> > >> > > http://developer.gimp.org/api/2.0/glib/glib-Timers.html> > >> > > 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....> > >> > > Ben> > >> > > 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: > > [EMAIL PROTECTED]: [EMAIL PROTECTED]: Re: Query > > execution time - MySQLCC: [EMAIL PROTECTED] 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: > > http://www.bigresource.com/MYSQL-what-is-execution-time-of-a-query-based-on-was-a-mysql-question--0PxW0B3P.html > > ) 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):http://forums.mysql.com/read.php?108,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-b
y-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 > > <[EMAIL PROTECTED]> 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.comhttp://clk.atdmt.com/UKM/go/msnnkmgl0010000006ukm/direct/01/> > 
> > _________________________________________________________________> > > > Great deals on almost anything at eBay.c
o.uk. Search, bid, find and > > win on eBay today!> > > > http://clk.atdmt.com/UKM/go/msnnkmgl0010000004ukm/direct/01/> > >> > > --> > > MySQL 
General Mailing List> > > For list archives: http://lists.mysql.com/mysql> > > To unsubscribe: > > http://lists.mysql.com/[EMAIL PROTECTED]> > >> > > 
> > > ------------------------------------------------------------------------> > Miss your Messenger buddies when on-the-go? Get Messenger on your > > Mobile! 
<http://clk.atdmt.com/UKM/go/msnnkmgl0010000001ukm/direct/01/>
_________________________________________________________________
Be a Hero and Win with Iron Man
http://clk.atdmt.com/UKM/go/msnnkmgl0010000009ukm/direct/01/

Hi,

Not sure about this, but do profiles exist in 3? If so you could do set profile=1

mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)

mysql> select count(*) from visitor;
+----------+
| count(*) |
+----------+
|  2841878 |
+----------+
1 row in set (0.00 sec)

mysql> show profile;
+--------------------------------+-----------+
| Status                         | Duration  |
+--------------------------------+-----------+
| (initialization)               | 0.0000192 |
| checking query cache for query | 0.000042  |
| Opening tables                 | 0.000024  |
| System lock                    | 0.0000202 |
| Table lock                     | 0.0000512 |
| init                           | 0.000024  |
| optimizing                     | 0.0000205 |
| executing                      | 0.0001027 |
| end                            | 0.0000212 |
| query end                      | 0.0000242 |
| storing result in query cache  | 0.0001452 |
| freeing items                  | 0.0000215 |
| closing tables                 | 0.000021  |
| logging slow query             | 0.0000197 |
+--------------------------------+-----------+
14 rows in set (0.00 sec)

And there is no reason you couldn't do this from your program as well. I don't know what the possible performance impact would be, you don't get time measurements for free, unless it is done from an outside the server source..

Thanks,

Eric


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to