473,809 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Executed SQL-statements in a logfile?

Hi

Is it possible to see all kinds of executed SQL-statements in a logfile? If
yes, how do I do that and how much information does it log?

Thanks, Kenneth
Nov 12 '05 #1
6 9277
Take a look at the statement event monitor

Cheers
Serge
Nov 12 '05 #2
> Take a look at the statement event monitor

Thanks. I have now studied a little bit of the event monitor. I found out
that the DB2 statement cache stores packages and statistics for frequently
used SQL statements.

I have found a Dynamic SQL Snapshot Result:

Database name = SAMPLE
Database path = /home/smith/smith/NODE0000/SQL00001/

Number of executions = 2
Number of compilations = 1
Worst preparation time (ms) = 126
Best preparation time (ms) = 126
Rows deleted = 0
Rows inserted = 0
Rows read = 24
Rows updated = 0
Rows written = 0
Statement sorts = 0
Total execution time (sec.ms) = 0.060226
Total system cpu time (sec.ms) = 0
Total user cpu time (sec.ms) = 0
Statement text = select * from org
But does it only show the last executed SQL-statement? How do I take a
snapshot of the cache? I think it's the SQLCACHE_SNAPSH OT, but what will I
have to type in the command line?

I hope someone can come up with an answer. :-)

Thanks, Kenneth
Nov 12 '05 #3
Take a look at the SNAPSHOT table functions.

Cheers
Serge
Nov 12 '05 #4
You can also use the DB2 Recovery Expert to do Log Analysis if that is
what you want to do.

Larry Edelstein
Kenneth wrote:
Hi

Is it possible to see all kinds of executed SQL-statements in a logfile? If
yes, how do I do that and how much information does it log?

Thanks, Kenneth


Nov 12 '05 #5
> > Hi

Is it possible to see all kinds of executed SQL-statements in a logfile? If
yes, how do I do that and how much information does it log?

Thanks, Kenneth

Yes. There are two tools: First is the event monitor, which can be
used to log every single statement over some period of interest. It's
nice because you can have the information written to a SQL table.
Suppose you care about connections and statements. You could do:

connect to <database>
create event monitor susanne for statements
write to table connheader (table susanne.ch),
stmt (table susanne.stmt)
buffersize 32 nonblocked;
set event monitor susanne state 1;
-- now wait for stuff to happen (queries, connections...)
-- turn off the monitor
set event monitor susanne state 0;
-- see what you got
describe table susanne.stmt;
describe table susanne.ch;
-- query these. Example:
select
(case when stmt_operation = 1 then 'PREPARE'
when stmt_operation = 2 then 'EXECUTE'
when stmt_operation = 4 then 'OPEN'
when stmt_operation = 6 then 'CLOSE'
when stmt_operation = 7 then 'DESCRIBE'
else 'OTHER' end),
substr(stmt_tex t,1,60),
cast(timestampd iff(1, char(stop_time-start_time))/1000000.0 as
decimal(12,6)) as duration,
cast(system_cpu _time/1000000.0 as decimal(12,4)) as sys_cpu,
cast(user_cpu_t ime/1000000.0 as decimal(12,4)) as user_cpu
from susanne.stmt order by start_time fetch first 25 rows only;

The other tool is the snapshot monitor. Using a "dynamic SQL
statement snapshot", you can see all the statements in the statement
cache at the time you take the snapshot. Each statement is annotated
with a count of how many times it has been executed (by any user) and
how much total resources it has consumed since you last reset the
monitor. This is a different view in that it doesn't identify
individual executions, but aggregates over all of them.
Please refer to the manual for use. The snapshot monitor also has a
nice SQL interface.

Susanne Englert
DB2 Performance
IBM Silicon Valley Lab
Nov 12 '05 #6
What about Query Patroller?

su************* @gmail.com (Susanne Englert) wrote in message news:<2b******* *************** ****@posting.go ogle.com>...
Hi

Is it possible to see all kinds of executed SQL-statements in a logfile? If
yes, how do I do that and how much information does it log?

Thanks, Kenneth

Yes. There are two tools: First is the event monitor, which can be
used to log every single statement over some period of interest. It's
nice because you can have the information written to a SQL table.
Suppose you care about connections and statements. You could do:

connect to <database>
create event monitor susanne for statements
write to table connheader (table susanne.ch),
stmt (table susanne.stmt)
buffersize 32 nonblocked;
set event monitor susanne state 1;
-- now wait for stuff to happen (queries, connections...)
-- turn off the monitor
set event monitor susanne state 0;
-- see what you got
describe table susanne.stmt;
describe table susanne.ch;
-- query these. Example:
select
(case when stmt_operation = 1 then 'PREPARE'
when stmt_operation = 2 then 'EXECUTE'
when stmt_operation = 4 then 'OPEN'
when stmt_operation = 6 then 'CLOSE'
when stmt_operation = 7 then 'DESCRIBE'
else 'OTHER' end),
substr(stmt_tex t,1,60),
cast(timestampd iff(1, char(stop_time-start_time))/1000000.0 as
decimal(12,6)) as duration,
cast(system_cpu _time/1000000.0 as decimal(12,4)) as sys_cpu,
cast(user_cpu_t ime/1000000.0 as decimal(12,4)) as user_cpu
from susanne.stmt order by start_time fetch first 25 rows only;

The other tool is the snapshot monitor. Using a "dynamic SQL
statement snapshot", you can see all the statements in the statement
cache at the time you take the snapshot. Each statement is annotated
with a count of how many times it has been executed (by any user) and
how much total resources it has consumed since you last reset the
monitor. This is a different view in that it doesn't identify
individual executions, but aggregates over all of them.
Please refer to the manual for use. The snapshot monitor also has a
nice SQL interface.

Susanne Englert
DB2 Performance
IBM Silicon Valley Lab

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
9551
by: George Copeland | last post by:
This is a request for help fixing a SQL Server 2000/ADO problem on Windows XP. I would appreciate any useful assistance. PROBLEM: SQL Server access on my machine fails as follows: 1. All of my VB6 apps reference the following ADO typelib: Microsoft ActiveX Data Objects 2.7 Library Located at: c:\Program Files\Common Files\System\ADO\msado27.tlb
1
1473
by: rozrabiak | last post by:
Hi! How can I get percent of executed procedure in MSSQL Server, lik in Enterprise Manager and/or dbMgr2k ? I use Visual C# and MSDE. Thank's for help, gregory
0
1318
by: Debra Castro | last post by:
I have a backup job that occasionally gets this error and the backup fails. Microsoft SQL Server 2000 8.00.818 Standard Edition is running on Windows 2003. Does anyone have any ideas why this happens? I appreciate any comments. Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 3222: The WriteFileEx system function executed on file 'D:\Mssql7\Backup\database_db_.BAK' only wrote 112128 bytes, expected 983040.
2
4112
by: BoB Teijema | last post by:
Hi all, One of our companies is having problems with a query on a linked server. They have two servers, serverA and serverB. On serverA they have set up a linked server to serverB. Query: select * from oas_company where code = 'TEST'
5
2709
by: Krisnamourt Correia via SQLMonster.com | last post by:
I have one query that executes many times in a week. I created one Maintenances plan that Rebuild all index in my Database that has been executed at 23:40 Saturday until stop finished at Sunday. However at middle of week (Wednesday or Thursday), that query don’t return result like that must be. The time exceeded and the result are total wrong. I compare the normal executed plan and the “crazy” one that SQL create to mount result.
0
4133
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We have an schema (s1) on an Oracle 9i database with database links pointing to a schema (s2) on another Oracle 9i database.
8
4042
by: Marcel | last post by:
I have a problem with a PHP page that seems to get executed twice. I am running PHP5 ISAPI on 2003 server. The script is a PHP page with a form. When the form is submitted one record have to be inserted in the database but when i look at the database after submitting the form there are two(!) records inserted so it looks like the script is executed twice. Can this be a proxy-setting or an ISA`server related subject???
2
6699
by: Chris | last post by:
In SQL 2005 I have a stored procedure as below: @sub_no smallint OUTPUT BEGIN BEGIN TRANSACTION INSERT...INTO
10
3187
by: Bob | last post by:
Hi, i wrote code for inserting data into a table, but it runs twice. If i remove the line: "comd.ExecuteNonQuery()", then it runs once; but i thought that line was necessary for executing the sql command ... if i remove " oConnection.Open()", then error: "connection is not open". see my code: Dim oConnection As SqlConnection Dim comd As SqlCommand
1
1625
by: DR | last post by:
what are the memory caps for threads running as a CLR stored procedure executed by sql server 2005? is it limited by OS only or also by sql servers memory limits? e.g. lets say my clr stored procedure is executed by sql server 2005 then it creates 10 threads and each thread builds a giant array on the stack, is the limits of each array limited by sql server or the os? do these clr stored procedures run inside the sql server address space or...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10375
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3860
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.