How to Gather SQL Resource Consump6on Metrics in Oracle - - PowerPoint PPT Presentation

how to gather sql resource consump6on metrics in oracle
SMART_READER_LITE
LIVE PREVIEW

How to Gather SQL Resource Consump6on Metrics in Oracle - - PowerPoint PPT Presentation

How to Gather SQL Resource Consump6on Metrics in Oracle Karen Morton Sr. Technical Consultant 1 karen.morton@enkitec.com karenmorton.blogspot.com karen_morton If


slide-1
SLIDE 1

How ¡to ¡Gather ¡SQL ¡Resource ¡ Consump6on ¡Metrics ¡in ¡Oracle ¡

Karen ¡Morton ¡

  • Sr. ¡Technical ¡Consultant ¡
1 ¡
slide-2
SLIDE 2

karenmorton.blogspot.com ¡ karen_morton ¡ karen.morton@enkitec.com ¡

slide-3
SLIDE 3

If ¡you ¡can’t ¡measure ¡it, ¡you ¡can’t ¡manage ¡it. ¡ ¡

―David ¡Garvin ¡ ¡

3 ¡
slide-4
SLIDE 4

There ¡are ¡two ¡types ¡of ¡ performance ¡problems ¡in ¡this ¡ world... ¡

slide-5
SLIDE 5

1 ¡

¡Response ¡6me ¡

  • problems. ¡
slide-6
SLIDE 6

2 ¡

¡Inefficiencies ¡that ¡aren’t ¡response ¡

6me ¡problems. ¡

  • Yet. ¡
slide-7
SLIDE 7

Therefore... ¡

slide-8
SLIDE 8

¡ You ¡must ¡be ¡able ¡to ¡aOack ¡ response ¡6me ¡problems ¡for ¡ specific ¡tasks ¡that ¡the ¡business ¡ cares ¡about... ¡

slide-9
SLIDE 9

…even ¡if ¡they ¡are ¡inefficiencies ¡ that ¡aren’t ¡yet ¡no6ceable ¡as ¡user ¡ response ¡6me ¡problems. ¡

slide-10
SLIDE 10

Why ¡should ¡you ¡care? ¡

slide-11
SLIDE 11
slide-12
SLIDE 12

Because ¡

¡ ¡

costs ¡you ¡money ¡

waste ¡

slide-13
SLIDE 13

TCO ¡$$ ¡

Waste ¡

Labor ¡$$ ¡

Hardware ¡$$ ¡

SoWware ¡$$ ¡

slide-14
SLIDE 14

And ¡waste... ¡

slide-15
SLIDE 15

...makes ¡

  • ther ¡work ¡

go ¡slower… ¡

slide-16
SLIDE 16

...even ¡your ¡fast ¡stuff ¡

slide-17
SLIDE 17

Why ¡guess? ¡ When ¡you ¡can ¡know. ¡

slide-18
SLIDE 18

Resource ¡Consump6on ¡Metrics ¡

slide-19
SLIDE 19

¡ ¡Time ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

Resources ¡

& ¡

slide-20
SLIDE 20

Start ¡simple ¡ with ¡ AUTOTRACE ¡

slide-21
SLIDE 21

SQL> ¡SET ¡TIMING ¡ON ¡ ¡ SQL> ¡ALTER ¡SESSION ¡SET ¡ ¡ ¡ ¡STATISTICS_LEVEL ¡= ¡ALL; ¡

Can ¡also ¡use ¡/*+ ¡gather_plan_sta;s;cs ¡*/ ¡hint ¡

slide-22
SLIDE 22

SQL> ¡SET ¡AUTOTRACE ¡TRACEONLY ¡

slide-23
SLIDE 23
slide-24
SLIDE 24 24 ¡

Elapsed ¡6me: ¡34.10 ¡seconds ¡

slide-25
SLIDE 25 25 ¡
slide-26
SLIDE 26 26 ¡
slide-27
SLIDE 27

Want ¡more? ¡

slide-28
SLIDE 28

Mine ¡Shared ¡Pool ¡ V$ ¡Views ¡

slide-29
SLIDE 29

Find ¡the ¡sql_id ¡& ¡child_number ¡

Put ¡a ¡recognizable ¡comment ¡in ¡your ¡SQL ¡to ¡make ¡it ¡easy ¡to ¡find. ¡

slide-30
SLIDE 30

Retrieve ¡plan ¡using ¡ DBMS_XPLAN.display_cursor ¡ ('&sql_id','&child_no', ¡ 'ALLSTATS ¡LAST ¡+COST ¡+BYTES’) ¡

Other ¡op6ons ¡available: ¡+PEEKED_BINDS ¡+OUTLINE ¡+ADVANCED, ¡etc. ¡

slide-31
SLIDE 31 31 ¡
  • ­‑-­‑Es6mates-­‑-­‑ ¡
  • ­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑Actuals-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑-­‑ ¡
slide-32
SLIDE 32

Want ¡more? ¡

slide-33
SLIDE 33

SQL ¡Monitor ¡Reports ¡

slide-34
SLIDE 34

Automa6cally ¡generated ¡when ¡ SQL ¡consumes ¡5 ¡seconds ¡or ¡ higher ¡of ¡CPU ¡or ¡IO ¡6me ¡

No ¡need ¡for ¡/*+ ¡gather_plan_sta;s;cs ¡*/ ¡hint ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡or ¡STATISTICS_LEVEL ¡= ¡ALL ¡

slide-35
SLIDE 35

Can ¡use ¡ /*+ ¡monitor ¡*/ ¡ hint ¡

Can ¡turn ¡off ¡using ¡/*+ ¡no_monitor ¡*/ ¡hint ¡

slide-36
SLIDE 36 36 ¡

select ¡dbms_sqltune.report_sql_monitor ¡ (report_level=>'ALL', ¡ ¡ type=>'TEXT', ¡ ¡ sql_id=>'6x2sh0kvzac0t') ¡monitor_report ¡ ¡ from ¡dual; ¡ ¡

Types ¡= ¡(11.1) ¡TEXT, ¡HTML, ¡XML, ¡plus ¡(11.2) ¡EM, ¡ACTIVE. ¡

Generate ¡Report ¡for ¡any ¡SQL_ID ¡

slide-37
SLIDE 37 37 ¡

select ¡dbms_sqltune.report_sql_monitor ¡ (report_level=>'ALL', ¡ ¡ type=>'TEXT', ¡ ¡ session_id=>sys_context('userenv','sid') ¡ ) ¡monitor_report ¡ ¡ from ¡dual; ¡ ¡

Generate ¡Report ¡for ¡current ¡session ¡

slide-38
SLIDE 38 38 ¡
slide-39
SLIDE 39 39 ¡
slide-40
SLIDE 40 40 ¡
slide-41
SLIDE 41 41 ¡
slide-42
SLIDE 42

Want ¡more? ¡

slide-43
SLIDE 43

Ac6ve ¡Session ¡History ¡ (ASH) ¡ & ¡ Automa6c ¡Workload ¡Repository ¡ (AWR) ¡

Must ¡have ¡license ¡for ¡Diagnos;cs/Tuning ¡Pack ¡

slide-44
SLIDE 44

SQL> ¡@ashrp6 ¡ ¡ SQL> ¡@awrsqrpt ¡

slide-45
SLIDE 45

Want ¡more? ¡

slide-46
SLIDE 46

Extended ¡SQL ¡Trace ¡ dbms_monitor ¡ session_trace_enable ¡

slide-47
SLIDE 47 47 ¡

Remember: ¡ The ¡more ¡data ¡you ¡have, ¡ the ¡easier ¡problem ¡diagnosis ¡ will ¡be. ¡

slide-48
SLIDE 48 48 ¡

How ¡you ¡get ¡the ¡data ¡doesn’t ¡ really ¡maOer. ¡ Just ¡get ¡it. ¡

slide-49
SLIDE 49

Ques6ons ¡& ¡Answers ¡