473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create 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 9244
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_SNAPSHOT, 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_text,1,60),
cast(timestampdiff(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_time/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.google. 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_text,1,60),
cast(timestampdiff(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_time/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
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...
1
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
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...
2
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:...
5
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. ...
0
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...
8
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...
2
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
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...
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
1
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.