Beyond SQL Tuning: Insider's Guide to Maximizing SQL Performance Monday, Oct 22 10:30 a.m. - 11:15 a.m. Marriott Marquis (Golden Gate Level) - Golden Gate A Ashish Agrawal Group Product Manager Oracle Management Cloud Oracle Corporation OCT 22, 2018
Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, timing, and pricing of any features or functionality described for Oracle s products may change and remains at the sole discretion of Oracle Corporation.
Beyond SQL Tuning: Insider's Guide to Maximizing SQL Performance Automatic Workload Repository (AWR), Active Session History (ASH) and SQL monitoring hold a wealth of SQL performance data. SQL Analytics leverages the rich SQL data in AWR, ASH, and SQL monitoring data using purpose-built machine learning to provide unique insights into SQL performance problems for your enterprise databases running on premise or on cloud. In this session learn to recognize patterns of SQL performance issues across all your Oracle Databases; perform a historical, comparative analysis to find any SQL bottlenecks or plan regression; and identify SQL performance anomalies and their root causes
Program Agenda 1 2 3 4 5 Challenges for DBA in managing DB and SQL Performance DB and SQL - Diagnostics and Tuning Advanced Database and SQL Analytics Remediation Oracle Autonomous Database
Program Agenda 1 2 3 4 5 Challenges for DBA in managing DB and SQL Performance DB and SQL - Diagnostics and Tuning Advanced Database and SQL Analytics Remediation Oracle Autonomous Database
Challenges for DBA in managing DB and SQL Performance Find problem DB and SQL when DBAs are responsible for large number of databases Current tools focus on monitoring and diagnostics of one DB at a time Which DB and SQL is in most need of their attention in future? Being always reactive, how can a DBA be more proactive? Data collection and analysis needed Out of the box answers missing
Challenges for DBA in managing DB and SQL Performance Difficult to identify trends and patterns in DB and SQL performance Very little long term DB and SQL history Limited advanced analytics capabilities like correlation, trending Difficult to compare performance between production and staging DB
Program Agenda 1 2 3 4 5 Challenges for DBA in managing DB and SQL Performance DB and SQL - Diagnostics and Tuning Advanced Database and SQL Analytics Remediation Oracle Autonomous Database
Which Database Performance Diagnostics Tool to Use? Automatic Workload Repository AWR Reports Reports about performance and workload data from AWR Active Session History ASH Gathers fine-grain data about every active database session every second Automatic Database Diagnostics Monitor - ADDM Data Analysis and Problem Identification Findings and Advise on how best to resolve bottlenecks Real-time SQL and Database Operations Monitoring Provides in-depth diagnostics about SQL execution at row source level
Reactive Performance Management Unfortunately we are not always in control Use Oracle Enterprise Manager to deal with production issues Issue EM solution Analyzing transient performance problems ASH Analytics Diagnose persistent performance issues ADDM In-depth SQL performance analysis Real-Time SQL Monitoring Optimizing top SQL s with sub-optimal plans SQL Tuning Advisor
Program Agenda 1 2 3 4 5 Challenges for DBA in managing DB and SQL Performance DB and SQL - Diagnostics and Tuning Advanced Database and SQL Analytics Remediation Oracle Autonomous Database
Database Performance Analytics Collects performance metrics, AWR & ASH data Provides insights by running analytics on this data Stores 13 months worth of selective, aggregated AWR and ASH data Supports Oracle EE, Oracle SE, MySQL and MS SQL Server
Database Performance Analytics use cases: Out of the box answers Databases gradually degrading in performance Databases with unpredictable performance Inefficient databases not taking advantage of compute resources Automatic performance analysis of databases across enterprise
SQL Analytics: SQL Warehouse SQL warehouse collects SQL performance data ASH data aggregates, samples SQLSTATs SQL Text SQL execution Plan hash value Automatic performance analysis of SQLs consuming more than 1% Database Time Scalable for 1000 s of databases Drill down into a set of SQL/ individual SQL to narrow down cause of a trend or an anomaly Supports Oracle Enterprise Edition with Diagnostics Pack
SQL Analytics use cases: Out of the box answers Identify SQLs with performance degradation, unpredictable performance, inefficient SQLs and changing execution plans Identify Top SQLs by resource usage Compare SQL performance across databases (production vs. staging) SQL Performance Insights
OMC Architecture With Gateway and OEM Integration REST APIs APM Agent Cloud Agent HTTPS (3872,1830-1839) HTTPS (3872,1830-1839) Gateway HTTPS (3872,1830-1839) HTTPS (443) Corporate Proxy (optional) HTTPS (443) End User OEM Repository SSH SQL Data Collector Corporate Firewall End User 16
Identify problem DBs that needs attention Performance Degradation - Identify databases whose performance has degraded over time and is correlated with change in demand - Identify negative correlations between performance trends and demand Variable Performance - Symptomatic of unpredictable workload and application response times - Identify databases with high degree of variance in SQL response time Database Inefficiency - Database workloads where large % of the database time in spent in application waits (not on CPU or I/O) - Not taking advantage of compute resources - For example enq: TX row lock contention, library cache lock
Databases with performance degradation Analyzing Demand with Database Time Demand = Executions and Activity = Database Time Linear regression technique used to analyze Activity and Demand Database Degradation with decrease in demand Database Degradation without change in demand Change in Response Time Change in Demand > + 20% < -10 % > +20% Between -10 % and +10%
Databases with unpredictable performance Applications workloads needs very stable and predictable Response Times Important to focus on DBs with unpredictable performance Relative variability of SQL = stdev(sql Response Time) / avg(sql Response Time) Variant SQL when relative variability > 1.66 To calculate the % of workload caused by variant SQL: For each db{ 1) Calculate which SQLs are variant over the time period 2) Calculate the elapsed time for each variant SQL 3) Variant workload performance = sum( step 2) / total elapsed time on db}
Inefficient databases not taking advantage of compute resources Inefficient wait time is in Active Sessions which are not part of CPU Time, IO wait Time and idle wait events Examples of inefficient waits are library cache lock, enqueue waits etc Inefficient (%) = inefficient wait time / IO + CPU + inefficient wait time Increasingly inefficient among the most inefficient databases = DBs with inefficient (%) > 50 % and inefficiency (%) increasing over time
Inefficient databases not taking advantage of compute resources View and compare the breakdown of inefficient waits, CPU and IO wait Check estimated database performance that can be gained by eliminating inefficient waits Focus on increasingly inefficient databases This databases and workloads represent the best tuning opportunity, so that the application can perform even better
Identify problem SQLs and SQL Performance Insights that needs attention Degrading SQL Response Time increases by more than 20% by linear regression Variant (unpredictable) SQLs Relative variability > 1.66 Inefficient SQL SQL with inefficiency > 20% by linear regression SQLs with execution plan changes Execution plan hash value of the SQL changes Top SQLs by resource usage SQL Performance Insights Consumes a disproportionate amount of system resources Commonality and unique findings across enterprise wide SQL performance issues
Identify degrading SQLs Identifies SQLs that were good but now turned bad Is the degradation due to same workload or change in magnitude of same workload Provides fine grained details of an individual SQL for a particular database Execution plan hash values can help identify cause of degradation - Increase in execution time with same plan or different plan Look up for same SQL across multiple databases and find out if it s system wide regression or limited to a database
Identify variant (unpredictable) SQLs Identify SQLs whose Response Time is unpredictable and varying Identify the nature of degradation - slowly building vs sudden change vs cyclic pattern Recommended to focus on this SQL to get more predicable workload performance Relative variability SQL Response Time 0 and < than 1.66 Predictable and stable > than 1.66 Unpredictable > than 3.0 Highly unpredictable
Identify inefficient SQLs Identify SQLs that are cause of a particular inefficiency - Example lock waits caused by row level locking or explicit lock commands Waits are application related Individual SQL level inefficiency Trend inefficiencies issues at SQL level Reducing inefficient waits will result in improved SQL performance - Increasing hardware resources or power will typically have limited impact on performance and improving efficiency - Improving application code and logic is required to make the application more efficient
Identify SQLs with execution plan changes Fast running queries may turn slow if the new execution plan is bad SQL query changing plans frequently may be variant in performance Identifies SQLs with changing execution plans by tracking execution plan hash values Stale/Missing statistics Overly general statistics or incorrect histograms Improper optimizer configuration Upgraded database: new optimizer Changing statistics (refresh) Changing data (plans do not scale with data) Bind-sensitive SQL with bind peeking Not parallelized (no scaling to large data) Improperly parallelized (skews, RAC, etc.)
Identify Top SQLs by resource usage Causes a large impact on database performance Identify high-load SQL using Top SQLs by CPU and IO across the enterprise wide DB s Identify SQLs which have the highest growth in CPU and IO usage using color key Group by various dimensions Active Sessions, Executions/Hour, Average Response Time. I/O Time, CPU Time
SQL Performance Insights Clustering to see commonality across enterprise wide SQL performance issues 14 of the 23 degrading SQLs have increasing I/O Time above 50% 6 of the 8 variant SQLs have plan changes 22 of the 51 degrading SQLs have increasing CPU Time above 50% Statistical analysis to find issues with more impact n sqls that contribute to 80% of dbtime Automatic baselines and anomaly detection for individual SQL Histogram of SQL execution Response Time
Compare SQL performance across databases (production vs. development) Compare SQL performance trend across databases for the same SQL by - Average Response Time, Executions Per Hour, I/O Time, CPU Time Compare SQL performance trend across execution plan hash value for the same SQL within the same database by - Average Response Time, Executions Per Hour, I/O Time, CPU Time Helps to identify SQL A degrading in production but not in staging DB Compare execution plan hash value A before upgrade of DB to execution plan hash value B after upgrade
Program Agenda 1 2 3 4 5 Challenges for DBA in managing DB and SQL Performance DB and SQL - Diagnostics and Tuning Advanced Database and SQL Analytics Remediation Oracle Autonomous Database
Remediation There is no one-size-fits-all Degrading SQL Response Time increases by more than 20% by linear regression SQL Tuning Advisor SQL Access Advisor Variant (unpredictable) SQLs Relative variability > 1.66 Database, OS, storage tuning SQL Plan Management Inefficient SQL SQL with inefficiency > 20% by linear regression Application Tuning SQLs with execution plan changes Execution plan hash value of the SQL changes SQL Plan Management Top SQLs by resource usage Consumes a disproportionate amount of system resources SQL Tuning Advisor SQL Access Advisor
Program Agenda 1 2 3 4 5 Challenges for DBA in managing DB and SQL Performance DB and SQL - Diagnostics and Tuning Advanced Database and SQL Analytics Remediation Oracle Autonomous Database
Oracle Autonomous Database Autonomous DB will automate most tasks for the infrastructure DBA App DBA still needs to monitor, diagnose and perform basic app-level administrative operations OMC provides management capabilities for these operations Deep performance diagnostics and troubleshooting Cross tier application diagnostics Performance analytics - trending and utilization analytics based on historical data Move Analyze Monitor Manage Diagnose
Cross-tier Application Diagnostics What s Really Happening in the Application? Challenge DBAs have no visibility on how the applications have been written Need for a common source of information and context that can be used by both application support and DBA teams (Devops) Solution Complete visibility of application performance, from the app to the database Rapidly identify the root cause of slowdowns for both application and database tiers Deep visibility into SQL execution, resource consumption and DB Time to help devops rapidly identify the root cause of application bottlenecks
Cross-tier Application Diagnostics: APM Integration
Cross-tier Application Diagnostics: App to SQL drill-down
Analyze: Performance Analytics Why: Poorly written applications will not perform efficiently even in Autonomous DB Solution: Database Performance Analytics Analyze Autonomous Database workloads to identify inefficiency caused by high waits and SQL performance variability Solution: SQL Analytics Drill down to SQLs contributing to high inefficiency and determine root cause of inefficiency
Conclusion Database and SQL Performance Analytics across enterprise Rapid time to value and lower operating costs Provides trends and key insights to SQL performance problems Helps you to be proactive in future problem avoidance Maximize database and SQL performance Increase business productivity by analyzing and remediating enterprise wide causes of database and SQL performance problems
Oracle Management Cloud END USER EXPERIENCE / ACTIVITY APPLICATION MIDDLE TIER DATA TIER VIRTUALIZATION TIER INFRASTRUCTURE TIER Global threat feeds Cloud access Identity Real users Synthetic users App metrics Transactions Server metrics Diagnostics logs Host metrics VM metrics Container metrics Configuration Compliance Tickets & Alerts Security & Network events Infrastructure Monitoring Log Analytics Configuration & Compliance Application Performance Monitoring Security Monitoring & Analytics Unified SaaS Platform Orchestration IT Analytics Comprehensive, Intelligent Management Platform Zero-effort Operational Insights Automated Preventative & Corrective Actions
Q & A feel free to ask 43