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 > Enable SQL Query traces on db2diag.log

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-09, 05:29
RASE RASE is offline
Registered User
 
Join Date: Jan 2009
Posts: 5
Exclamation Enable SQL Query traces on db2diag.log

Hello,

I want to capture the sql query executed by the application to be captured on the db2diag.log file on the DB2 side. I have set the db2 trace level to 4. (default is 3 i believe). Still i am not able to get the SQL query stmt on the db2diag.log file.

Please let me know how to enable this to get the SQL query stmt on DB2DIAG.LOG file under the <<db2_inst_admin_home>>/sqllib/db2dump

Thanks and Regards,
Rase.
Reply With Quote
  #2 (permalink)  
Old 01-26-09, 06:44
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by RASE

Please let me know how to enable this to get the SQL query stmt on DB2DIAG.LOG file under the <<db2_inst_admin_home>>/sqllib/db2dump
There is no way of doing that. You could create an event monitor for statements, but the information would go to a different place. You can read more in the manual.
Reply With Quote
  #3 (permalink)  
Old 01-26-09, 11:05
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
you might want to try db2trc (see db2 manuals)
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #4 (permalink)  
Old 01-26-09, 13:01
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The db2diag.log is intended for, well, diagnostic purposes in case something goes wrong. It is not an audit facility, so queries shouldn't be written there (except for diagnostic purposes). I would use the existing mechanisms (like event monitors) and work with them.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 01-27-09, 02:56
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
Another easier way for doing the same is "get snapshot for all applications"
whenever all your queries are running. Repeat the same in frequent interval (like 5 minutes etc). Open the SNAPSHOT files one after another, and get a hint of the SQL queries running on the database with important facts like (Lockwait, Compiler Cost, Rows-Read Vs Rows Selected, Users running the query, Application Active/Idle time etc). Don't forget to RESET the MONITOR before you start the above excercise.
__________________

Jayanta Datta
DB2 UDB DBA
IBM India, Global Delivery
New Delhi
Reply With Quote
  #6 (permalink)  
Old 01-29-09, 20:20
RASE RASE is offline
Registered User
 
Join Date: Jan 2009
Posts: 5
Hello All,

Thanks for your suggestions.

One more general query on enabling the traces on DB2. If i set my trace level to the max (to 4) and try running these kind of snapshots on a very frequent intervals, will it affect the performance of the DB server (say for a 100~150 user connected to the server)

Regards.
RASE
Reply With Quote
  #7 (permalink)  
Old 01-30-09, 02:16
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Tracing, diagnostic information, and snapshots are completely different things. Setting the DIAGLEVEL (not trace level) to 4 does not have an influence on capturing snapshots. You should only set the DIAGLEVEL that high if instructed by IBM support. Otherwise, level 3 (default) is typically used.

Collecting snapshots very frequently will have an impact on performance, of course, because you put additional load on the system. However, that additional work should be minimal and I rather doubt that you will be able to exactly measure it. In any case, I hope you don't want to do that to capture all SQL statements that way? Because this wouldn't work.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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