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 > Extract last executed queries

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-07-11, 04:59
Alethesnake Alethesnake is offline
Registered User
 
Join Date: Sep 2011
Posts: 4
Extract last executed queries

Hi all,

I am looking for a way to extract from our db2 udb database (v. 9.5) the queries executed during the last 1-2 days.
Reading on this forum I found a link to a "DB2 Monitor" tool that shows them, but what I need is to extract last the queries throught a view (I didn't find one that shows the last days history) or a clp command.

Any suggestion?

Thanks in advance,

Alessandro.
Reply With Quote
  #2 (permalink)  
Old 09-07-11, 06:24
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
you can start event monitoring
see for detail
Collecting information about database system events
or use the get snapshot with dynamic sql option
or use sysibmadm administrative views ..
all detail at the same place
__________________
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
  #3 (permalink)  
Old 09-07-11, 09:12
Alethesnake Alethesnake is offline
Registered User
 
Join Date: Sep 2011
Posts: 4
Hi przytula_guy,

Thanks for your answer. I'd like to avoid to start an event monitor because it's our production database and I must follow a long iter.
About the remaining solutions I already tried the views of sysibmadm schema but what I found was only views that shows just heavy query or cpu expensive query, executing queries, but nothing that lists all the queries of the last two/three days.

So I tried

get snapshot for dynamic sql on <mydatabase>

but I get the following error and I don't know how to solve:

Quote:
SQL1096N The command is not valid for this node type.

SQL1096N The command is not valid for this node type.

Explanation:

A command was issued on a node that does not support the command, or the
system environment was found to be set up incorrectly for this node
type. For example, a database was cataloged as LOCAL on a client node.

The command cannot be processed.

User response:

Verify that the command and parameters are correct for the node type.
Also verify that the environment where the command is to be processed is
correct. Resubmit the command.
How can I solve it?

Thanks,

Alessandro.
Reply With Quote
  #4 (permalink)  
Old 09-07-11, 09:24
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
I executed this
db2 get snapshot for dynamic sql on clsm <-- in db2inst1 := instance owner
and no problem
are you local in the instance owner...
__________________
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
  #5 (permalink)  
Old 09-07-11, 09:46
Alethesnake Alethesnake is offline
Registered User
 
Join Date: Sep 2011
Posts: 4
I tried to execute the "get snapshot" statement directly on the server and it runs.
Via the clp on my local machine I tried the one you suggested:

Code:
get snapshot for dynamic sql on <mydatabase> in <myinstanceowner>
but I suppose I misunderstood your suggestion because it doesn't run, I get an error about "IN" clause no expected in that position.

Looking at the result of the command (on the server) it seems the same result I get with:

Code:
select * from SYSIBMADM.SNAPDYN_SQL
Isn't it?
Reply With Quote
  #6 (permalink)  
Old 09-07-11, 09:55
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
yes - get snapshots can be produced with dynamic admin views doing similar operation as get snapshot
__________________
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
  #7 (permalink)  
Old 09-07-11, 10:07
Alethesnake Alethesnake is offline
Registered User
 
Join Date: Sep 2011
Posts: 4
Ok thanks, when I saw it for the first time I was snared by the "snapshot_timestamp" field..
My problem is now that the view contains only data related to the executed query. Is there a way to link it to the user that launches it, the ip of its machine, and the real time the query was executed?
Reply With Quote
  #8 (permalink)  
Old 09-08-11, 04:28
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
with event monitor you get this - similar to get snapshot for application agentid xxx

DUOW correlation token = 10.104.116.63.40191.110908065504
Application name = db2jcc_application
Application ID = 10.104.116.63.40191.110908065504
UOW start timestamp = 09/08/2011 08:55:04.942245
UOW stop timestamp = 09/08/2011 08:55:05.768879
UOW completion status = Committed - Commit Statement
__________________
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
Reply

Tags
db2 9.5, dynamic sql, history

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