Upload
others
View
28
Download
0
Embed Size (px)
Citation preview
Creating My Own PL/SQL
Performance Monitoring Tool
using PL/SQL and APEXWhy do DBA’s get all the cool tools?
Gary J. Propeck, Ph.D.
2/15/2018RMOUG Training Days 2018
1
Objectives
Develop an Application around the PL/SQL Profiler (DBMS_PROFILER)
Monitor PL/SQL Profiler Data Collection
Create Baselines and Thresholds
Report Threshold Violations during PL/SQL execution.
Use only Oracle-supplied tools
SQL Developer (17.2.0)
Application Express (APEX 5.1.3)
Oracle RDBMS 12.1.0.2
SQL*Plus
2/15/2018RMOUG Training Days 2018
2
Objectives
Demonstrate PL/SQL Programming Techniques
Anonymous Blocks
Named Procedures
Named Functions
Packages
Package Body
Package Specification
Triggers
2/15/2018RMOUG Training Days 2018
3
Objectives
Use PL/SQL “Encapsulation”.
No Privileges for Select, Insert, Update, or Delete granted on tables.
Data Entered and Manipulated via:
PL/SQL
APEX
Create Package to invoke PL/SQL Profiler (DBMS_PROFILER).
2/15/2018RMOUG Training Days 2018
4
MOTIVATIONWhy do this?
2/15/2018RMOUG Training Days 2018
5
Motivating Factors
Unemployment?
Business?
Retirement?
2/15/2018RMOUG Training Days 2018
6
Why do DBA’s get all the cool Oracle
tools?
Oracle Enterprise Manager (OEM)
AWR
ADDM
ASH
Metrics and Baselines
2/15/2018RMOUG Training Days 2018
7
But…
Why?
2/15/2018RMOUG Training Days 2018
8
Install the PL/SQL Profiler
2/15/2018RMOUG Training Days 2018
9
Install the PL/SQL Profiler
$ORACLE_HOME\rdbms\admin
proftab.sql
PLSQL_PROFILER_RUNS
PLSQL_PROFILER_DATA
PLSQL_PROFILER_UNITS
profload.sql
DBMS_PROFILER
2/15/2018RMOUG Training Days 2018
10
PLSQL_PROFILER_RUNSInstalled into user schema
2/15/2018RMOUG Training Days 2018
11
PLSQL_PROFILER_DATAInstalled in user schema
2/15/2018RMOUG Training Days 2018
12
PLSQL_PROFILER_DATAInstalled in user schema
2/15/2018RMOUG Training Days 2018
13
DBMS_PROFILERRUN AS SYSDBA
2/15/2018RMOUG Training Days 2018
14
Create Procedures to invoke and
stop PL/SQL Profiler
2/15/2018RMOUG Training Days 2018
15
Create Procedures and Functions for
Starting and Stopping the PL/SQL Profiler
start_profiler_proc1.pls
start_profiler_proc2.pls
start_profiler_func1.pls
start_profiler_func2.pls
2/15/2018RMOUG Training Days 2018
16
Start_profiler_proc2.pls
2/15/2018RMOUG Training Days 2018
17
2/15/2018RMOUG Training Days 2018
18
Test using an Anonymous Block
2/15/2018RMOUG Training Days 2018
19
The Anonymous Block
2/15/2018RMOUG Training Days 2018
20
Capture The Anonymous Block
2/15/2018RMOUG Training Days 2018
21
Results
2/15/2018RMOUG Training Days 2018
22
Test using a Named Procedure
2/15/2018RMOUG Training Days 2018
23
Compare the Anonymous Block to a
Named Procedure
2/15/2018RMOUG Training Days 2018
24
Compare the Anonymous Block to a
Named Procedure
2/15/2018RMOUG Training Days 2018
25
Does Flushing the Shared Pool change
Performance
2/15/2018RMOUG Training Days 2018
26
Using DBMS_PROFILER to Demonstrate the Effectiveness of the Shared Pool
2/15/2018RMOUG Training Days 2018
27
Display Data with APEX
2/15/2018RMOUG Training Days 2018
28
Query for APEX Chart
2/15/2018RMOUG Training Days 2018
29
APEX App Home Page
2/15/2018RMOUG Training Days 2018
30
Chart of Execution - Flush Shared Pool
for Each Execution
2/15/2018RMOUG Training Days 2018
31
Chart of Execution - Flush Shared Pool
for First Execution
2/15/2018RMOUG Training Days 2018
32
Create a PL/SQL Package
2/15/2018RMOUG Training Days 2018
33
Benefits of a PL/SQL Package
2/15/2018RMOUG Training Days 2018
34
Package Specification
2/15/2018RMOUG Training Days 2018
35
SQL Developer Code Snippets
2/15/2018RMOUG Training Days 2018
36
Compare Explicit Cursor Fetch
SyntaxesBasic Fetch
Cursor For Loop
Bulk Collect
2/15/2018RMOUG Training Days 2018
37
Basic Fetch
2/15/2018RMOUG Training Days 2018
38
Cursor For Loop
2/15/2018RMOUG Training Days 2018
39
Bulk Collect
2/15/2018RMOUG Training Days 2018
40
View Result Data in APEX
2/15/2018RMOUG Training Days 2018
41
Regular Fetch in APEX
2/15/2018RMOUG Training Days 2018
42
Regular Fetch Chart with Average
2/15/2018RMOUG Training Days 2018
43
Regular Fetch Chart with Average
and Standard Deviations
2/15/2018RMOUG Training Days 2018
44
Build a semi-automatic Collection
SystemTables
PL/SQL Package
PL/SQL Triggers
APEX
Test
2/15/2018RMOUG Training Days 2018
45
Create New User TOPT_PROF
Schema – TOPT_PROF
Owns PL/SQL Profiler Tables
OWNS TOPT_PROF Collection Tables
Owns TOPT_PROF_PKG
Grants EXECUTE on TOPT_PROF_PKG to PUBLIC
NO SELECT, INSERT, UPDATE, DELETE Privileges Granted on TOPT_PROF Tables
Schema Owner GPRO1 owns COMP_REG_BULK and demo table
2/15/2018RMOUG Training Days 2018
46
Create Collection Tables
TOPT_PROF_COLLECTIONS
TOPT_PROF_BASELINE
TOPT_PROF_VIOLATIONS
2/15/2018RMOUG Training Days 2018
47
DBMS_SCHEDULER Job
2/15/2018RMOUG Training Days 2018
48
Create an Issue with the Cursor Query
Alter index BIG_TAB_OWNER_IDX invisible;
Query cannot use index
2/15/2018RMOUG Training Days 2018
49
TOPT_PROF_APP APEX Application
2/15/2018RMOUG Training Days 2018
50
APEX FORM on Table
TOPT_PROF_COLLECTIONS
2/15/2018RMOUG Training Days 2018
51
Regular Fetch Chart of Profiler Runs
2/15/2018RMOUG Training Days 2018
52
Create Baseline (and Threshold 3 STD.)
2/15/2018RMOUG Training Days 2018
53
Chart with Baseline and Threshold
2/15/2018RMOUG Training Days 2018
54
Create an Issue with the Cursor Query
Alter index BIG_TAB_OWNER_IDX invisible;
Query cannot use index
2/15/2018RMOUG Training Days 2018
55
Chart with Induced Error
2/15/2018RMOUG Training Days 2018
56
Reporting Threshold Violations
2/15/2018RMOUG Training Days 2018
57
TO-DO List
Send email notification
Incorporate the Hierarchical Profiler
Clean up and standardize APEX Application
2/15/2018RMOUG Training Days 2018
58
FINAL THOUGHTSYes we can!!!
www.theoldprotraining.com
2/15/2018RMOUG Training Days 2018
59