If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Displaying Elapse Time

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-25-09, 00:38
fany fany is offline
Registered User
 
Join Date: Jun 2009
Posts: 8
Displaying Elapse Time

Hello everybody..

I have a problem when i do my final project from my campus.
my Question is: How to display the elapse time when we execute some query(selection, updating, deleting, ect) in DB2??

For example, when i execute a query for selection (Select....from...), i can not get the elapse time. So, how to display it?

I am a beginner for DB2 and i need your help..
Reply With Quote
  #2 (permalink)  
Old 06-25-09, 07:23
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
That certainly depends on what tool you use to execute the query. You could try "time db2 select whatever" on Linux or Unix, or db2batch (on any platform).
Reply With Quote
  #3 (permalink)  
Old 06-25-09, 21:19
fany fany is offline
Registered User
 
Join Date: Jun 2009
Posts: 8
How to get the "time db2 select whatever" on Linux or Unix, or db2batch (on any platform)" as you told just now?

is there any menu to choose? or by execute query??

I'm sorry because I am a beginner so it is difficult for me..

best regarsd...
Reply With Quote
  #4 (permalink)  
Old 06-25-09, 22:22
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You can get the current time as follows:

db2 "select current_timestamp from sysibm.sysdummy1"

However, there is overhead in running the above SQL that will affect your results if you compare the starting and ending times.

You can get elapsed time of queries inside of DB2 (not counting network traffic back to client) by running a "snapshot for dynamic SQL" (see Command Reference Manual). You will need to turn on the statement monitor in the dbm cfg.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 06-27-09, 01:58
fany fany is offline
Registered User
 
Join Date: Jun 2009
Posts: 8
thank u for your advice..

i mean, how to display the elapse time when i execute a query??
not to display the current time..

I tried to run a snapshot for dynamic SQL, but i can not see the elapse time of queries..
Reply With Quote
  #6 (permalink)  
Old 06-27-09, 05:54
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
db2 udpate monitor switches using statement on
db2 connect to <db-name>
db2 flush package cache dynamic
db2 reset montitor switches

run your sql

db2 get snapshot for dyanmic sql on <db-name> > snapshot.out
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 06-28-09, 22:19
fany fany is offline
Registered User
 
Join Date: Jun 2009
Posts: 8
Thank u Marcus..

I've tried your solution to display the elapse time..
I have executed this query:
GET SNAPSHOT FOR DYNAMIC SQL ON TEST

TEST is the database's name..

when i executed that query, the result is "Not Collected"..
i don't understand what is the meaning of that...

could you like to help me anymore??
how to display the elapse time by using that query??
is there any mistakes so why the "not collected" command is displayed on the monitor??

Thank you very much
Reply With Quote
  #8 (permalink)  
Old 06-28-09, 22:56
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I am not sure what you are doing wrong, but you must leave the session open for the commands I gave you. Do not close the session before the snapshot is taken.

You can also permanently turn on the statement monitor with this command, which might work for you.

Do this once:
db2 update dbm cfg uisng DFT_MON_STMT ON
db2stop
db2start

For each snapshot:
db2 connect to TEST
db2 flush package cache dynamic
db2 reset montitor switches

run your sql

db2 get snapshot for dyanmic sql on TEST > snapshot.out
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #9 (permalink)  
Old 07-01-09, 00:44
fany fany is offline
Registered User
 
Join Date: Jun 2009
Posts: 8
oh i'm sorry marcus..

I've tried to do all your solution, but the result is always "not collected"

i don't understand why this happen..

This is the result when i execute : get snapshoot...
Number of executions = 2
Number of compilations = 1
Worst preparation time (ms) = 3
Best preparation time (ms) = 1
Internal rows deleted = Not Collected
Internal rows inserted = Not Collected
Rows read = Not Collected
Internal rows updated = Not Collected
Rows written = Not Collected
Statement sorts = Not Collected
Statement sort overflows = Not Collected
Total sort time = Not Collected
Buffer pool data logical reads = Not Collected
Buffer pool data physical reads = Not Collected
Buffer pool temporary data logical reads = Not Collected
Buffer pool temporary data physical reads = Not Collected
Buffer pool index logical reads = Not Collected
Buffer pool index physical reads = Not Collected
Buffer pool temporary index logical reads = Not Collected
Buffer pool temporary index physical reads = Not Collected
Buffer pool xda logical reads = Not Collected
Buffer pool xda physical reads = Not Collected
Buffer pool temporary xda logical reads = Not Collected
Buffer pool temporary xda physical reads = Not Collected
Total execution time (sec.microsec)= Not Collected
Total user cpu time (sec.microsec) = Not Collected
Total system cpu time (sec.microsec)= Not Collected
Total statistic fabrication time (milliseconds) = Not Collected
Total synchronous runstats time (milliseconds) = Not Collected
Statement text = select * from t_Buku

why the result is not collected too??

i am very confuse...

Reply With Quote
  #10 (permalink)  
Old 07-01-09, 00:56
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Please run the following command and post the output here:

db2 get dbm cfg

To output the data to a file, run this:

db2 get dbm cfg > dbm_cfg.txt
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #11 (permalink)  
Old 07-01-09, 11:29
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
The output of "db2 get monitor switches" would also help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On