copyright © 2006 quest software toad ® database administration best practices presenter
TRANSCRIPT
Production Database Pressure Points
Diagnostics and Optimization
IncreasedUser ActivityIncreased
User Activity
upgrade
PlatformChangesPlatformChanges
ProductionDatabase
develop
ApplicationChanges
ApplicationChanges
End UsersDevelopers
DBAs
Shrinking Batch
Windows
Shrinking Batch
Windows
What is “Best Practice” ?
• A set of guiding principles proposed by industry leading experts• Acknowledgement that the application is part of an evolving
lifecycle which will continue to iterate over a period of time• Determination to deliver a quality product or what we used to call
“taking pride in your work” !
Why use it ?
Challenges to implementing Best Practice
• Resistance to use tools
• Already have scripts
• Yada yada….
• Access to data model– Ensures
development matches business requirements
– Ensures data model is correctly optimized
– Ensures model integrity is maintained
– Version history
Design
Deploy (1)
• DDL Scripts automatically generated from data model• Alter Script generation based on data model updates• Version History retained for auditing• Application scalability testing
Deploy (2)
• Will the application work correctly and adequately under production conditions ?
SQL statement or PL/SQL code scalability
profile
Does not scale well
Scales well
Detect/Discover
• Environment (O/S and Database)– Instance Manager
– UNIX Monitor
– Windows Service Manager
• Instance Performance– Database Browser (all instances)
– Database Monitor
– Database Probe
• SQL Performance– SQL Trace/Optimization
– ASH Report
– Index Monitoring
• Space Management– Database Browser
– Segment Advisor
– Top Session Finder– SQL Monitor– SQL Scan/SQL Detective (Xpert/Dev Suite)
– Database Health Check– Session Browser– ADDM/AWR– StatsPack
– Space/IO History– Undo Advisor
– Database Browser (all instances)– Database Monitor – Oracle Alert Log analysis (FTP and Telnet windows)
Diagnose• Instance Performance
– Database Probe
– Database Monitor
– Session Browser
– Health Check
• SQL Performance– Top Session Finder
– SQL Trace/Optimization
– Session Browser
– SQL Optimization (Xpert or Dev Suite)
• Space Management– Segment Advisor
– Tablespace Map
– Identify Space Deficits
– Log Switch Frequency Map
– Undo Advisor
Resolve• Instance Performance
– Oracle Parameters
• Schema/Data Integrity– Log Miner (access to Undo SQL) - Flashback Table– Schema Compare– Data Compare– Data Duplicates
• SQL Performance– Explain Plan– SQL Optimization (Xpert or Dev Suite)
• Space Management– Rebuild Multiple Objects– Analyze Objects– Repair Chained Rows– Segment Shrink Advisor– DBMS Redefinition Wizard
SQL Optimization - How hard can it be to rewrite SQL ?
How many different ways can you write this query?
SELECT EMP_NAME,DPT_NAME,GRD_DESC FROM EMPLOYEE, DEPARTMENT DEPARTMENT1, GRADE WHERE EMP_GRADE = GRD_ID AND EMP_DEPT = DPT_ID AND EXISTS (SELECT 'X' FROM DEPARTMENT DEPARTMENT2 WHERE DPT_AVG_SALARY IN (SELECT
MIN(DPT_AVG_SALARY) FROM DEPARTMENT DEPARTMENT3) AND DPT_ID = EMPLOYEE.EMP_DEPT);
30,491 !!!
Teach Yourself SQL in 30,420 Minutes
By Gabriel F. Gargiulo
• Proactively identify problematic SQL directly from the source code
• Thorough transformation of SQL producing every possible semantically equivalent rewrite
• Optimize SQL in batch in context of source code
• Generate replacement script
• Automatic ranking of best alternatives
• Minimal involvement which can save hours of time
Optimize SQL
Inform• Instance Performance
– ADDM/AWR
– StatsPack
– Health Check Report (schedulable)
• Schema Integrity– Schema Compare
– HTML Schema Report (schedulable)
– Reports Manager (schedulable)
– ER Diagram (Toad Data Modeler)
– Master-Detail Browser
• SQL Performance– Plan Change Analyzer (Xpert or Dev Suite)
• Space Management– Tablespace History
– IO History
Administer• Instance
– ASM Manager
– Oracle Parameters
– Redo Log Manager
– Schema Browser (Rollback Segment, Jobs, Scheduler)
• Schema Integrity– Object Audit
– NLS Parameters
– Export & Import
• Space Management– Schema Browser (Tablespaces)
– Tablespace Menu
• Users– Audit SQL / Sys Privs
– Schema Browser (Users, Roles, Object Privs, etc)
– DBMS Flashback– Recycle Bin