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 > get snapshot for dynamic sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-14-06, 09:54
samu78nyc samu78nyc is offline
Registered User
 
Join Date: Nov 2006
Posts: 31
get snapshot for dynamic sql

Hi all,
OS-AIX
DB2 - V8, FixPak7
I am trying to find the longest running query using the command ..
get snapshot for dynamic sql on <db_name>
The above command is listing all the quries on the db but I need to find out the longest running query..
Thanks in advance..
Reply With Quote
  #2 (permalink)  
Old 12-14-06, 10:37
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You could use the snapshot functions in a query. Something like this:

select * from table(snapshot_dyn_sql('MYDB',-1)) as x order by total_exec_time desc fetch first 5 rows only

Andy
Reply With Quote
  #3 (permalink)  
Old 09-02-11, 07:36
db2cap db2cap is offline
Registered User
 
Join Date: May 2010
Posts: 87
Hi,
Continuing the very old post instead of creating a new. As recommended, we only enable switches as and when required. If asked to kill the longest running query so as to bring down the CPU utilization, I will first turn on the monitor switch for statements and timestamp (on by default). But this will not capture data for work in execution. How do I find the longest running query in such case?

Thanks,
db2cap
Reply With Quote
  #4 (permalink)  
Old 09-02-11, 08:36
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by db2cap View Post
How do I find the longest running query
Uhm...
Code:
SELECT * FROM SYSIBMADM.LONG_RUNNING_SQL
ORDER BY ELAPSED_TIME_MIN DESC
?

How's the "long running" part related to CPU utilization though?
Reply With Quote
  #5 (permalink)  
Old 09-02-11, 08:48
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
DB2 - V8, FixPak7
not all sysibmadm views are available if any ....
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #6 (permalink)  
Old 09-02-11, 09:58
db2cap db2cap is offline
Registered User
 
Join Date: May 2010
Posts: 87
przytula_guy: caught the point...
Actually we still have some of our databases on V8 which unfortunately does not have those easy to manage administrative views.

n_i, you did not got the pitch of my point actually. Even if I use SYSIBMADM.LONG_RUNNING_SQL view, will turning on the monitor switches immediately start gathering the data which otherwise is not collected for the running queries?

Kindly refer the below post for better understanding:
Statement text in LONG_RUNNING_SQL
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