Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-16-2008, 01:40 PM
Neil Tompkins
 
Posts: n/a
Default Query execution time - MySQL

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 etc

Thanks,
Neil
__________________________________________________ _______________

All new Live Search at Live.com

http://clk.atdmt.com/UKM/go/msnnkmgl...ukm/direct/01/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-16-2008, 01:40 PM
Craig Huffstetler
 
Posts: n/a
Default Re: Query execution time - MySQL

Greetings 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-wha...-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 query

or

mysql

run 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...404#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 Huffstetler
xq on FreeNode #mysql | #apache

On Wed, May 14, 2008 at 6:13 AM, Neil Tompkins <neildtompkins@hotmail.com>
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 etc
>
> Thanks,
> Neil
> __________________________________________________ _______________
>
> All new Live Search at Live.com
>
> http://clk.atdmt.com/UKM/go/msnnkmgl...ukm/direct/01/


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-16-2008, 01:40 PM
Neil Tompkins
 
Posts: n/a
Default RE: Query execution time - MySQL

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 Customersthe 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@gmail.comTo: mysql@lists.mysql.comSubject: Re: Query execution time - MySQLCC: neildtompkins@hotmail.comGreetings 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-wha...-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-lineof 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...404#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 theresults 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 whyit 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 haveany 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@hotmail.com> 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.co.uk. Search, bid, find and win on eBay today!
http://clk.atdmt.com/UKM/go/msnnkmgl...ukm/direct/01/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-16-2008, 01:40 PM
Ben Clewett
 
Posts: n/a
Default Re: Query execution time - MySQL

If you using 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: craig.huffstetler@gmail.comTo: mysql@lists.mysql.comSubject: Re: Query execution time - MySQLCC: neildtompkins@hotmail.comGreetings 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-wha...-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...404#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@hotmail.com> 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.co.uk. Search, bid, find and win on eBay today!
> http://clk.atdmt.com/UKM/go/msnnkmgl...ukm/direct/01/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-16-2008, 01:40 PM
Ben Clewett
 
Posts: n/a
Default 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: ben@clewett.org.uk
> > To: neildtompkins@hotmail.com
> > CC: craig.huffstetler@gmail.com; mysql@lists.mysql.com
> > Subject: Re: Query execution time - MySQL
> >
> > If you using 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:

> craig.huffstetler@gmail.comTo: mysql@lists.mysql.comSubject: Re: Query
> execution time - MySQLCC: neildtompkins@hotmail.comGreetings 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-wha...-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...404#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@hotmail.com> 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.co.uk. Search, bid, find and

> win on eBay today!
> > > http://clk.atdmt.com/UKM/go/msnnkmgl...ukm/direct/01/

> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe:

> http://lists.mysql.com/mysql?unsub=n...ns@hotmail.com
> >

>
>
> ------------------------------------------------------------------------
> Miss your Messenger buddies when on-the-go? Get Messenger on your
> Mobile! <http://clk.atdmt.com/UKM/go/msnnkmgl0010000001ukm/direct/01/>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-16-2008, 01:40 PM
Neil Tompkins
 
Posts: n/a
Default RE: Query execution time - MySQL

Hi Ben

I running on Windows. I think I need a solution where i can get the searchtime within my sql query. Is this possible. At the moment I;m running mysql server version 3.28

Neil



> Date: Wed, 14 May 2008 13:44:22 +0100> From: ben@clewett.org.uk> To: neildtompkins@hotmail.com> 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: ben@clewett.org.uk> > > To: neildtompkins@hotmail.com> > > CC: craig.huffstetler@gmail.com; mysql@lists.mysql.com> > > Subject: Re: Query execution time - MySQL> > >> > > If you using C++ then you can use this:> > >> > > http://developer.gimp..org/api/2.0/glib/glib-Timers.html> > >> > > I use this in my code, does anexcelent 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 isthe 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@gmail.comTo: mysql@lists.mysql.comSubject: Re: Query > > execution time - MySQLCC: neildtompkins@hotmail.comGreetings 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 andget it back > > to you for whatever usage statistic you are looking to measure. ( See: > > http://www.bigresource.com/MYSQL-wha...-0PxW0B3P.html > > ) or for usage inJDBC 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 moredetail on what the output will > > be):http://forums.mysql.com/read.php?108,51989,142404#msg-142404> > > > SELECT * FROM user_log; 15113 rows fetchedin 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 (fortotal time it took on your > > server/P.C. or wherever you are running thequery...). 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 yourunning? 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@hotmail.com> 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.co.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/mysql?unsub=neildtompkins@hotmail.com> > >> > > > > > ------------------------------------------------------------------------> > Miss your Messenger buddies when on-the-go? Get Messenger on your > > Mobile! <http://clk.atdmt.com/UKM/go/msnnkmgl0010000001ukm/direct/01/>

__________________________________________________ _______________
Win Indiana Jones prizes with Live Search
http://clk.atdmt.com/UKM/go/msnnkmgl...ukm/direct/01/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-16-2008, 01:40 PM
Neil Tompkins
 
Posts: n/a
Default RE: Query execution time - MySQL

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

Neil



> Date: Wed, 14 May 2008 13:44:22 +0100> From: ben@clewett.org.uk> To: neildtompkins@hotmail.com> 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: ben@clewett.org.uk> > > To: neildtompkins@hotmail.com> > > CC: craig.huffstetler@gmail.com; mysql@lists.mysql.com> > > Subject: Re: Query execution time - MySQL> > >> > > If you using C++ then you can use this:> > >> > > http://developer.gimp..org/api/2.0/glib/glib-Timers.html> > >> > > I use this in my code, does anexcelent 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 isthe 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@gmail.comTo: mysql@lists.mysql.comSubject: Re: Query > > execution time - MySQLCC: neildtompkins@hotmail.comGreetings 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 andget it back > > to you for whatever usage statistic you are looking to measure. ( See: > > http://www.bigresource.com/MYSQL-wha...-0PxW0B3P.html > > ) or for usage inJDBC 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 moredetail on what the output will > > be):http://forums.mysql.com/read.php?108,51989,142404#msg-142404> > > > SELECT * FROM user_log; 15113 rows fetchedin 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 (fortotal time it took on your > > server/P.C. or wherever you are running thequery...). 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 yourunning? 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@hotmail.com> 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.co.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/mysql?unsub=neildtompkins@hotmail.com> > >> > > > > > ------------------------------------------------------------------------> > 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/msnnkmgl...ukm/direct/01/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-16-2008, 01:40 PM
Eric Frazier
 
Posts: n/a
Default Re: Query execution time - MySQL

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: ben@clewett.org.uk> To: neildtompkins@hotmail.com> 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: ben@clewett.org.uk> > > To: neildtompkins@hotmail.com> > > CC: craig.huffstetler@gmail.com; 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: > > craig.huffstetler@gmail.comTo: mysql@lists.mysql.comSubject: Re: Query > > execution time - MySQLCC: neildtompkins@hotmail.comGreetings 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-wha...-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 > > <neildtompkins@hotmail.com> 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/mysql?unsub=neildtompkins@hotmail.com> > >> > > > > > ------------------------------------------------------------------------> > 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/msnnkmgl...ukm/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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:07 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290