School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,149 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,693 people online right now. Registration is fast and FREE... Join Now!




Query Timer

 

Query Timer, How to put a timer in a query

woodjom

18 Jun, 2009 - 12:08 PM
Post #1

D.I.C Regular
Group Icon

Joined: 8 May, 2008
Posts: 366



Thanked: 15 times
My Contributions
Ok, i have seen hints and suggestions about incorporating a microtimer in a query. What i have not seen is the way to actually implement it. I ahve done several good searches but think i may not be using the correct keyword to pop up what i am looking for.

Basically, i need to be able to trach the time it took to perform a query and spit it out in the footer of the site for debugging purposes.

Any points to good keywords would be great.

User is offlineProfile CardPM
+Quote Post


June7

RE: Query Timer

19 Jun, 2009 - 02:24 PM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Dec, 2008
Posts: 485



Thanked: 38 times
My Contributions
I don't know about a timer in a query but could use variables that hold the start and stop times before and after the query runs and then calculate and report the difference. If takes less than a second, do you really care?
This link suggests 'use GetTickCount in Delphi' but doesn't explain how
http://forums.mysql.com/read.php?49,136523,136606#msg-136606
search for GetTickCount led me to
http://msdn.microsoft.com/en-us/library/ms724408.aspx

This post has been edited by June7: 19 Jun, 2009 - 02:32 PM
User is offlineProfile CardPM
+Quote Post

kzimmerm

RE: Query Timer

23 Jun, 2009 - 09:29 AM
Post #3

D.I.C Head
**

Joined: 8 Feb, 2009
Posts: 67



Thanked: 3 times
My Contributions
QUOTE(woodjom @ 18 Jun, 2009 - 12:08 PM) *

Ok, i have seen hints and suggestions about incorporating a microtimer in a query. What i have not seen is the way to actually implement it. I ahve done several good searches but think i may not be using the correct keyword to pop up what i am looking for.

Basically, i need to be able to trach the time it took to perform a query and spit it out in the footer of the site for debugging purposes.

Any points to good keywords would be great.



What I've done is this:

CODE


declare @Timer datetime
set @Timer = getdate()
<your code goes here>
.
.
.
.
print datediff(ms, @Timer, getdate())



You can also use :

CODE


SET STATISTICS TIME { ON | OFF }



Hope this helps.

Kurt

User is offlineProfile CardPM
+Quote Post

woodjom

RE: Query Timer

23 Jun, 2009 - 06:19 PM
Post #4

D.I.C Regular
Group Icon

Joined: 8 May, 2008
Posts: 366



Thanked: 15 times
My Contributions
Yeah im on a 3 month learning curve with SQL2k5.

I kinda figured that i needed to declare a variable that obtained the time you entered the query, it was the getting the time at the end of the query that i was wondering. Ill try the datediff function and see how that works.

And im not going to be console timing this....im trying to do this within the queries (stored-procedures and functions). For statistical purposes ill probably end up have several datediff variables (i know they will in themselves consume time) but i plan on using them to speed up the queries if they need to be speed up.
User is offlineProfile CardPM
+Quote Post

xerxes333

RE: Query Timer

24 Jun, 2009 - 06:03 AM
Post #5

D.I.C Regular
Group Icon

Joined: 5 Jul, 2007
Posts: 454



Thanked: 24 times
Dream Kudos: 25
My Contributions
Create a table that can store the execution times and use datediff so you can run reports on the times.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 04:29PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month