1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Creating an Event Monitor for Statements doc

15 350 0
Tài liệu được quét OCR, nội dung có thể không chính xác
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Creating an Event Monitor for Statements
Thể loại Document
Định dạng
Số trang 15
Dung lượng 728,41 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Creating an Event Monitor for Statements management of event monitoring data easy ¢ Need SYSADM or DBADM to create a table event monitor CREATE EVENT MONITOR stmtmon FOR STATEMENTS W

Trang 1

Creating an Event Monitor for Statements

management of event monitoring data easy

¢ Need SYSADM or DBADM to create a table event monitor

CREATE EVENT MONITOR stmtmon

FOR STATEMENTS

WHERE APPL_NAME = ‘NEWAPP’ AND

AUTH_ ID = ‘BBDS’

WRITE TO TABLE IN event_tblspace

A table event monitor streams event records to SQL tables, this makes capture, parsing, and

(y= REDUCE IMPACT

BUFFERSIZE 2000

NONBLOCKED

OR

OR

Trang 2

sample Output: Statement Event Monitor Query

* FROM W

* FROM W

* FROM W

WE

INT

* FROM W

= We

* FROM W

FROM WE

XT INTO WE_

Trang 3

Vionitoring Interfaces

¢ Administrative Views

» Easy-to-use application programming interface

» Execute administrative functions through SQL

¢ Table functions MON_GET_

„ Introduced in DB2 9.7

» Enhanced reporting and monitoring of the database

system, data objects, and the package cache

» Ligntweight - has a lower impact on the system than existing system monitor and snapshot interfaces

Trang 4

interfaces — Find

¢ Administrative Views

x LONG RUNNING SQL (Time, Statement, Status)

¢ Table Functions

» MON GET ACTIVITY DETAILS ( Executing v Waiting)

» MON GET PKG CACHE_SIMT ( Filtering Options)

Trang 5

SQL — High CPU TIME

Example: List top 10 SQL statements by cou time

varchar(stmt_text,200) as statement,

num_exec_with_metrics as numExec,

TOTAL _CPU_ TIME

FROM TABLE(MON_ GET PKG CACHE STMT ('D', NULL, NULL, -2)) as T WHERE T.NUM EXEC WITH METRICS <> 0

ORDER BY AVG _CPU_TIME desc

fetch first 10 rows only;

Trang 6

Results from Top Ten CPU consumers

Database Administration - sqixeditor_project/Script1.sql - IBM Optim Database Administrator -—- Oo xX

Eile Edit Navigate Search Project Data Run Script Window Help

|r3x MH & | & | Hr | Bir Ble Or Or

(= EE SQL Resuie s** &B PYF S, '

| Type query expression here | “Status | Result1 |

Status | Operation MEMBER | SECTION_TYPE | STATEMENT - NUMEXEC _AVG_CPU_TIME

v Succeed Run SQL SELECT MEMBER,

v Succeed Run SQL varchar(stmt_text,

v Succeed Run SQL

@ Failed RunSQL

( Ji WE_Y9NKFD.J12.WE_0G0_47 SET value=200 V 1497

a) D

3 0 D UPDATE WE_Y9NKFD.!12.WE_0G0_ 83460 SET value=2( 1477 25289

@ Failed Run SQL 4 0 D UPDATE WE_Y9NKFD.J12.WE_0G0_25099 SET value=2( 1487 25224

6 0 D UP

> 0 D UP Column name: STATEMENT

Column data type: VARCHAR

8 0 D UP —

UPDATE WE_Y9NKFDJ12.WE_0G0_47 SET value=200 WHERE id= Ea

9 0 D UP} (SELECT id FROM WE_Y9NKFDJ12.WE_0GO_47 ORDER BY RAND()

10 0 D up| FETCH FIRST 1 ROWS ONLY)

=

ca m TRE mm.)

(XI TT) Toial 10 records shown

| ne Displayed 6 of 6 results: 4 succeeded, 2 failed, 0 terminated, 0 warning, 0 critical error | | = [E] |

Trang 7

Analyzing SQL

e¢EXPLAIN TOOLS

Now we will see,

how well the costly SQL executes

¢ VISUAL EXPLAIN

Trang 8

Information Management

xplain date and time: 09/03/2009 10:43:09AM Parallelism: None

ata Joiner: No

oO 0:

\

tal cost{timerons): 140.01

SQL Explain Tools gy RETURN(1) 140.01 h

E

D

T

» Easy to quickly spot the problem

» Provides drill down functionality <fecoums

» Multiple images can be stored for

A

¢ Text Based

» Can be used with any interface (=

» All the information is contained on a single Ct

» Format output with db2exfmt es

ị 3) PRODUCT DIM q.0863628 lộ

0

i

35 INDEX: DB2Z2INST1 IDxX9931622560?008 00

1i; tr

Trang 9

Why use Explain’

¢ To seek performance tuning opportunities

» How are tables being accessed?

» How useful are additional indexes?

» Does rewriting the query help?

¢ Comparisons: To understand changes in query performance due to:

» Changes in the data model

» Changes in the data

» Changes in configuration parameters

¢ View statistics used at time of optimization and current performance

Trang 10

VISUAL EXPLAIN

are

9 Access

plan graph

1 Tables

2 Indexes

3 Statistics

4 Configuration Parameters

be Explain

Snapshot

Trang 11

riow to use Visual Explain

Invoke from

» Data Studio toolset

»% Control Center

Enter SQL to be analyzed

» Trap the poor running SQL statement either from your program, performance monitors or create a brand new statement

» The text can then just be typed or copied into the input box

Output

» Explain Information stored in Explain Tables

„Detailed information

«Manipulate Explain information using SQL

x Access Plan Graph

For dynamic and static SQL statements

Trang 12

Visual Explain Interface

¢ Every object in the visual explain interface can be drilled down for

additional information

¢ Cost

x The estimated total resource usage necessary to execute the access plan for

a statement The unit of cost is the timeron

¢ Timeron

x Timeron is a combination of CPU cost (in number of instructions) and VO (in numbers of seeks and page transfers)

» In general if you have a larger number of timerons your query will run slower

¢ All of the run times of the individual components are cumulative and are measured in timerons

Trang 13

Visual Explain Interface — Access Plan Diagram

Data - sqixeditor project/Script2:sql - IBM Optim Database Administrator

File Edit Navigate Search Project Data Run Script CLICK TO FIND PREFERENCES FOR VISUAL EXPLAIN

CONTROLS: OPEN, SAVE ACCESS PLAN GRAPH

= =

SCALE GRAPH TO FIT

Overview of Diagram hk An

| |

| Basic Information

Information that identifies the diagram (1IRETURN

Explain Timestamp: 2010-02-11T06:26:41

[D) View the SOL Statement

lS] Save Diagram

lagram Overview

ST Teen ciagram overview am ISOLATE SPECIFIC SECTIONS OF ACCESS PLAN GRAPH

| & Description of Selected Node La | [>]

Trang 14

Visual Explain Interface — View SQL Statement

® Help a Access Plan Diagram &

SGmAaAAaH | B

4 ~~ Canvas ——

Q Overview of Diagram

Basic Information

Information that identifies the diagram

View SQL Statement Link

Database Platform: LUW

Database Version: DB2 v09.07.1

Optimized SOL Tab

(ORETUR

8421.97

` v

(2)GRPBY

\ 8421.93 |

SQL Statement 1 mSQL Statement 2

Display the selected diagram overview SELECT | by, i

P.prod_name,

| SUM (F.quantity) FROM

sales_fact F, product_dim P, store_dim S, date_dim D WHERE F.day_date = D.day_date and F.prod_code = P.prod_code and F.store num = S.store num

Ngày đăng: 21/01/2014, 23:20

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w