Lesson 3 | Basic SQL tuning tools |
Objective | Explain the tool set for SQL tuning. |
Oracle SQL Tuning Tools
SQL Analyze Utility
- With the Oracle Enterprise Manager open, click the Oracle SQL Analyzer button.
- Read the opening screen, and click OK.
- Now we are ready to begin. Select the bottommost database under the Databases folder.
- Select Top SQL from the mon1 database.
- The TopSQL Options box will allow you to control the number of disk reads as well as apply various filters. Click OK.
- Choose our database to view the init.ora parameters for SQL values. Select select/*+rule*/ a.db_name.
- Click the SQL Text tab to view the full SQL text.
- Place your cursor anywhere in the SQL text field and click to highlight the text.
- In an actual Oracle environment, you would press Ctrl+C to copy this text and Ctrl+N to move to a new screen. For the purposes of this simulation, press Enter to move to a new SQL screen.
- For the purposes of this simulation, place your cursor in the SQL statement window and hit Enter to paste your SQL text. You would normally accomplish this by pressing Ctrl+V.
- Typically, you would press F9 to see the rule-based explain plan, but for the purposes of this simulation press Enter.
Oracle SQL Analyze
Oracle SQL Analyze can be used to identify and correct problem SQL statements. SQL Analyze allows you to sort SQL statements by various performance metrics, and acquire detailed tuning information for any SQL statements. Wizards are included which guide the user through a SQL optimization methodology or add hints to existing SQL statements.
Oracle Index Tuning Wizard
The Index Tuning Wizard provides an easy solution to the Index Tuning problem. It automatically identifies tables which would benefit from index changes, presents its findings for verification, and allows you to implement the index tuning recommendations.
In later lessons, we will be going deeper into SQL analyzer to show how it can be used to tune SQL queries.
In the next lesson we will look at how SQL is executed within the Oracle engine.
"Oracle Expert" has been deprecated
Oracle Expert is no longer a standalone feature in current Oracle database versions It was a separate tool available in earlier versions (up to Oracle 10g) to analyze performance issues and provide tuning recommendations.
Here's how Oracle has evolved its tuning capabilities:
- Integrated Functionality: Oracle has integrated many of Oracle Expert's features into its core database management tools, including:
- Automatic Workload Repository (AWR): Collects and analyzes performance statistics.
- Automatic Database Diagnostic Monitor (ADDM): Identifies performance bottlenecks and suggests corrective actions.
- SQL Tuning Advisor: Analyzes SQL statements and recommends tuning actions.
- SQL Performance Analyzer (SPA): Tests the impact of tuning changes before implementation.
- Cloud-Based Tools: Oracle also offers cloud-based tools for database management and tuning, such as:
- Oracle Enterprise Manager Cloud Control: Provides a comprehensive view of database performance and allows for proactive tuning.
- Oracle Cloud Infrastructure (OCI) Database Management: Offers automated tuning and optimization features for databases in the Oracle Cloud.
Key Advantages of the Integrated Approach:
- Streamlined Workflow: Tuning tools are directly embedded within the database management environment, simplifying the process.
- Real-Time Analysis: Performance data is continuously collected and analyzed, enabling proactive tuning.
- Cloud Integration: Cloud-based tools offer additional automation and scalability for database management.
Recommendations for Tuning Oracle Databases:
- Leverage the Integrated Tools: Utilize AWR, ADDM, SQL Tuning Advisor, and SPA to identify and address performance issues.
- Consider Cloud-Based Tools: Explore Oracle Enterprise Manager Cloud Control or OCI Database Management for enhanced tuning capabilities in cloud environments.
- Stay Updated: Keep your database software up-to-date to benefit from the latest tuning features and best practices.
- Consult Documentation: Refer to Oracle's official documentation for detailed guidance on using the available tuning tools effectively.
When to Use the EXPLAIN PLAN Statement
Use the EXPLAIN PLAN statement to determine the execution plan Oracle Database follows to execute a specified SQL statement. This statement inserts a row describing each step of the execution plan into a specified table. You can also issue the EXPLAIN PLAN statement as part of the SQL trace facility. This statement also determines the cost of executing the statement. If any domain indexes are defined on the table, then user-defined CPU and I/O costs will also be inserted. The definition of a sample output table PLAN_TABLE is available in a SQL script on your distribution media. Your output table must have the same column names and datatypes as this table. The common name of this script is UTLXPLAN.SQL. The exact name and location depend on your operating system.
Oracle Database provides information on cached cursors through several dynamic performance views:
- For information on the work areas used by SQL cursors, query V$SQL_WORKAREA.
- For information on the execution plan for a cached cursor, query V$SQL_PLAN.
- For execution statistics at each step or operation of an execution plan of cached cursors (for example, number of produced rows, number of blocks read), query V$SQL_PLAN_STATISTICS.
- For a selective precomputed join of the preceding three views, query V$SQL_PLAN_STATISTICS_ALL.
- Execution statistics at each step or operation of an execution plan of cached cursors are displayed in V$SQL_PLAN_MONITOR if the statement execution is
monitored. You can force monitoring using the MONITOR hint.