The Query Optimizer in Oracle Database 19C What's New?

The Query Optimizer in Oracle Database 19C What's New?

The Query Optimizer in Oracle Database 19c What’s New? Christian Antognini @ChrisAntognini antognini.ch Christian Antognini • Senior principal consultant and partner at Trivadis • Focus: get the most out of database engines • Logical and physical database design • Query optimizer • Application performance management • Author of Troubleshooting Oracle Performance @ChrisAntognini antognini.ch Agenda • All Environments • Reporting on Hint Usage • Execution Plan Comparison Refer to the Oracle • Online Statistics Gathering Enhancements Database SQL Tuning Guide • Enterprise Edition with Management Packs for technical information • Statistics Maintenance Enhancements about the new features • Real-Time SQL Monitoring for Developers • Enterprise Edition on Exadata The Database Licensing • Automatic Resolution of Plan Regressions Information User Manual • High-Frequency SPM Evolve Advisor Task provides information about • Real-Time Statistics their availability • High-Frequency Automatic Statistics Collection • Quarantine for Runaway SQL Statements • Automatic Indexing Disclaimer • This presentation covers the versions 19.[3-5] • This presentation does not cover the query optimizer features that are specific to the Autonomous Database services All Environments Reporting on Hint Usage • It is an issue to verify whether hints added to SQL statements are actually used • To make it easier, there is a new section in the output generated by the DBMS_XPLAN.DISPLAY* functions • The new section (Hint Report) reports hints into two categories • Valid (used) • Invalid (either unused, unresolved or having syntax error) • For invalid hints, additional information explaining the issue might be provided Execution Plan Comparison • When dealing with the performance of SQL statements, it is rather usual to compare execution plans • The new function DBMS_XPLAN.COMPARE_PLANS implements a logical (i.e. not line by line) comparison of two or more execution plans • The execution plans can be stored in either a plan table, the cursor cache, the AWR, a STS, a SQL baseline, a SQL profile or an advisor task • The report can be generated in either text, HTML or XML format • It does not work in Standard Edition (bug 30488154) • An ORA-13631 is raised Online Statistics Gathering Enhancements • Up to and including 18c, bulk load operations in empty segments do not gather index statistics • As of 19c, according to the documentation, this restriction no longer exists • In practice, because of a bug, it is only partially the case • Statistics on non-unique indexes are not gathered Enterprise Edition with Management Packs Statistics Maintenance Enhancements • Up to and including 18c, ALTER TABLE operations that move, merge and coalesce partitions do not maintain global and partition-level statistics • As of 19c, according to the documentation, this restriction no longer exists • Histograms are not maintained • In practice, because of bugs, it is only partially the case • Most global statistics are not (correctly) maintained • Partition-level statistics are maintained PART Real-Time SQL Monitoring for Developers • All database users, without specific privileges, can generate real-time monitoring reports about SQL statements they executed • The API to generate the reports is the regular one SELECT dbms_sql_monitor.report_sql_monitor(sql_id => '...', type => 'active') FROM dual • There are new (undocumented) views to see which statements were monitored and how they were executed • V$ALL_SQL_MONITOR • V$ALL_SQL_PLAN_MONITOR • V$ALL_SQL_PLAN • V$ALL_ACTIVE_SESSION_HISTORY TUN Enterprise Edition on Exadata On-premises and Exadata Cloud Service Automatic Resolution of Plan Regressions • Up to and including 18c, by default, the SPM Evolve Advisor only considers SQL statements already loaded in SQL plan baselines • As of 19c, the advisor can also consider other SQL statements • Only resource-intensive SQL statements with several execution plans • New SQL plan baselines can be automatically created • To control the feature, use DBMS_SPM.SET_EVOLVE_TASK_PARAMETER • To enable it set ALTERNATE_PLAN_BASELINE to AUTO (default in 19.3) • To disable it set ALTERNATE_PLAN_BASELINE to EXISTING (default in 19.4+) • 19c also improves the selection of the execution plans stored into CC/AWR/STS High-Frequency SPM Evolve Advisor Task • By default, the SPM Evolve Advisor runs daily in the maintenance window • In 19c it can be configured to also run outside of the maintenance window • To control it, the DBMS_SPM.CONFIGURE procedure supports a new parameter • AUTO_SPM_EVOLVE_TASK (OFF, ON, AUTO) • In 19c AUTO is equivalent to ON • When enabled, it runs every hour for no longer than 30 minutes Real-Time Statistics • They do not replace object statistics, their purpose is to augment them between two gatherings • They are limited to specific object statistics and to INSERT/UPDATE/MERGE • Number of rows and blocks at the table level • Low/high value at the column level • They are gathered and used by default • The NO_GATHER_OPTIMIZER_STATISTICS hint prevents their gathering • They are visible in *_TAB_STATISTICS and *_TAB_COL_STATISTICS • NOTES = STATS_ON_CONVENTIONAL_DML • Execution plans based on them are marked (V$SQL_PLAN.OTHER_XML) High-Frequency Automatic Statistics Collection • By default, the automatic statistics collection task runs daily in the maintenance window • In 19c it can be configured to also run outside of the maintenance window • To control it, the DBMS_STATS.SET_GLOBAL_PREFS procedure supports three new parameter • AUTO_TASK_STATUS (OFF, ON) • AUTO_TASK_INTERVAL (in seconds, default 900, minimum 60) • AUTO_TASK_MAX_RUN_TIME (in seconds, max/default 3600) • DBA_AUTO_STAT_EXECUTIONS provides information about the runs Quarantine for Runaway SQL Statements • The Resource Manager can be instructed to terminate SQL statements that either run for too long or consume excessive resources • When terminating a SQL statement, 19c automatically creates a quarantine configuration that prevents the execution plan to run • Instead, an ORA-56955 (quarantined plan used) is raised • Quarantine configurations • Can be managed and manually created with DBMS_SQLQ • Are visible in DBA_SQL_QUARANTINE • To be used do not necessarily require the activation of a Resource Manager plan • Cursors using them are marked (V$SQL.SQL_QUARANTINE) and externalize the number of avoided executions (V$SQL.AVOIDED_EXECUTIONS) Automatic Indexing ASTS • Brand new, game changer feature Identify candidate indexes • Expert system that automatically manages performance-related Create invisible indexes Drop unused indexes • Requires no external inputs indexes • Unsupervised • 24x7 SPA Make indexes Validate • Automatically adapts to changes visible/unusable performance • For identification and validation purposes, it uses an automatically Create SQL plan baselines managed SQL tuning set for regressions Automatic Indexing – Handling • By default, it is disabled • It can be enabled either in reporting mode or “fully” dbms_auto_index.configure('AUTO_INDEX_MODE', 'REPORT ONLY') dbms_auto_index.configure('AUTO_INDEX_MODE', 'IMPLEMENT') • Few parameters exist • Schema inclusion/exclusion lists • Retention of unused indexes and logs • Storage (tablespace, space budget, compression) • When enabled, it runs every 15 minutes • DBA_AUTO_INDEX_EXECUTIONS • DBMS_AUTO_INDEX.REPORT_(LAST_)ACTIVITY Summary • Licensing limitations make many (interesting) features not generally available • Small, but useful new features or enhancements • Finally DBMS_XPLAN reports hint usage • Online statistics gathering (index statistics + partition maintenance operation) • Real-time SQL monitoring available to everyone • Quarantine for runaway SQL statements • New concepts; real-world experience is needed to critically judge them • Automatic indexing could be a game changer • Real-time statistics • Automatic resolution of plan regressions • Execution plan comparison • Minor enhancements • High-frequency automatic statistics collection and SPM Evolve Advisor task .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    22 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us