SQL Plan Management Oracle – All You Need to Know About

While upgrading the Oracle database or making any changes in the system parameters, you might have noticed that some SQLs’ performance or queries get highly regressed. If this happens, then don’t worry it’s quite obvious and will always happen whenever there are any changes in the plan. But you can prevent this regression if you use SQL Plan Management Oracle.

In case you aren’t aware of what it is and how it can help, then this blog is surely meant for you. In this blog, we are going to cover every basic aspect related to the SQL plan management and that how it will help in preventing query or performance regression.

An Overview of SQL Plan Management Oracle

SQL Plan Management is a deterrent tool that allows the optimizer to manage SQL execution plans automatically while ensuring that only verified and known plans are used by the database.

SQL plan management uses a mechanism that lets the optimizer to use it for a SQL statement. This mechanism is known as a SQL Plan baseline. It’s a set of accepted plans. A plan is typically known to hold all plan-related information such as a set of hints, SQL plan identifier, optimizer environment, and bind values.

The optimizer uses this information for reproducing an execution plan. Commonly, the database accepts a plan into the plan baseline only after it verifies and confirms that the plan performs absolutely well.

In short, a SQL Plan management Oracle is a tool used for mitigating the risk of query regression when you upgrade to Oracle Database11g or 12c.

Key Components of SQL Plan Management

Mainly, there are three essential elements of SQL Plan management. They are as follows:

  • SQL Plan Baseline Capture

The component creates a SQL plan baselines that describes the accepted or trusted execution plan for all relevant SQL statements. If you aren’t sure where you can find the SQL plan baselines, then let us tell you that you can find the plan baselines stored in a plan history in the SQL Management Base. The management base will be found in the SYSAUX tablespace.

  • SQL Plan Baseline Selection

SQL Plan baseline selection makes sure that the tool uses only the accepted execution plans for statements that have a SQL plan baseline. Furthermore, it ensures that it tracks every new execution plan in the plan history for a statement. The plan history comprises both unaccepted and accepted plans. An unaccepted plan can either be rejected (verified but not performant) or unverified (newly found but not verified).

  • SQL Plan Baseline Evolution

This component is meant to assess every unverified execution plan for a given statement in the plan history for either to be accepted or rejected.

What’s the Main Purpose of SQL Plan Management?

SQL plan management oracle restricts performance or query regression due to any plan changes in the database. Secondly, this tool aims at gracefully adapting to changes.

It must be noted that if an event has caused any irreversible execution plan changes such as dropping an index, SQL plan baseline cannot help in this case.

Advantages of SQL Plan Management Oracle

SQL plan management can preserve or improve SQL performance in database systems and upgrades and data changes.

Some more specific benefits comprise the following-

  • When a database upgrade causes the installation of a new optimizer version, it usually results in plan changes for a small part of SQL statements. Due to plan changes, either the performance of the system improves or there isn’t any change literally. However, in some cases, plan changes result in performance regression and here’s where SQL plan baselines come into play. It significantly lessens potential regressions that result from an upgrade.
  • Ongoing data and system changes can have an impact on plans for some SQL statements potentially creating performance regressions. Plan baselines assist in reducing this performance regression. Further, it stabilizes the SQL performance of the system as well as the database.
  • Employing new application modules brings in new SQL statements into the database. The application software is likely to use the proper SQL execution plan that’s developed in a standard test configuration for the new statements. In case the system configuration differs from the test configuration, then the database can develop SQL plan baselines over time to produce better performance.

In the Bottom Line

During an automated or manual updating of statistics for some objects or while changing some parameters related to the optimizer, or any changes made in the system cause a drastic change in the execution plan. Even more dramatic change is noticed while a database is upgraded. While most plans lead to improvement as they are made to adapt to the new system environment, there are some that lead to performance regression as well. In such cases, we need a SQL plan management mechanism whose main work is to reduce the regression risk.

If you are stuck with long queries or if your system’s performance has reduced, you can get a SQL query optimization tool online. Tosska Technologies Limited is one such company that provides solutions and tools related to database and SQL related performance optimization and improvements. We use advanced technologies like AI (artificial intelligence) so that our tool can help you solve numerous tasks at a time.

Improve Oracle Database Performance Tuning with Tosska’s AI-Enabled Tools

improve oracle database performance tuning

Oracle database performance tuning is a crucial method for accelerating the application function and data retrieval process. In order to speed up the performance of the application, the developer or the database administrator has to expedite query response time. This implies that they must have a deep understanding of how well the database is organized and how it satisfies its purpose.

Generally, SQL tuning means minimizing the query plan steps which in turn decreases the wait time and time cost. There are a number of ways you can implement to performance tune your Oracle database. In most of the techniques, you would require changing the source code. However, at Tosska Technologies, you will get products that are AI-based and don’t require touching the source code. Let us introduce you to our amazing products that are extremely helpful in Oracle database performance tuning.

3 Brilliant Tools Offered by Tosska for Improve Oracle Database Performance Tuning

Tosska provides solutions for SQL and database related performance optimizations and improvements. We are one of the very few companies in the world that uses artificial intelligence technology to solve different database performance problems. We help our customers to minimize their hardware investment and increase their level of database application service.

We have enlisted below some tools provided by Tosska Technologies that help to improve Oracle database performance successfully.

  1. Tosska SQL Tuning Expert (TSE™) for Oracle®

It’s an innovative machine or SQL tuning tool that upgrades your SQL statements without involving the user. By just point and click, the tool will help you with the ultimate SQL performance solution. The only thing you are required to do is to enter your problematic SQL statement into the product and press the button.

You are free from doing any testing, guessing or analyzing during the complete SQL tuning process. The enhanced SQL statement will get benchmarked with your original SQL statement side by side without any doubt. It isn’t just another tool but provides users with better statistics analysis, query plan visualization, and more.

2. Tosska SQL Tuning Expert Pro (TSE Pro™) for Oracle®

One of the best parts of having this tool is that it will tune your Oracle database without touching your source code. Surprised? But, it’s true. Tosska SQL Tuning Expert Pro is a tool that helps in upgrading SQL performance without even touching the source code of the program. Besides this, users can even use various other performance query plans for different sizes of production databases without the need of keeping a number of versions of the program source. It is specially designed for package application users who don’t hold the source code of their applications.

With our SQL Tuning Expert Pro, SQL tuning gets even easier for application developers than ever before. You can improve the SQL statement without conducting any time-consuming test, program implementation, and integration test that are essential in the software development cycle. Apart from these brilliant SQL tuning attributes, strong indexes recommendation function is also given that assists users in reviewing and discovering more potential indexes that are extremely crucial but may be missing in the current database schema.

To be more specific, it’s an extremely brilliant and cost-aware index advice engine that lets users analyze their existing database schema- in case any new indexes are available that are helpful in enhancing an assigned SQL workload. The engine is capable of handling up to thousands of SQL statements and offers you a reasonable recommendation that even human experts are not able to accomplish.

3. Tosska In-Memory Maestro (TIM™) for Oracle®

Tosska In-Memory Maestro for Oracle is a tool that automates the process of optimizing In-memory SQL and offers recommendations for In-memory objects for a given SQL workload. Our proprietary artificial intelligence engine is highly beneficial in achieving the aforesaid. The tool also offers a user-friendly In-memory simulation function for users so that they can virtually estimate their in-memory table objects for one or more SQL workload captured from AWR or SGA without actually populating those table objects.

Final Words

Nowadays, most of the highly succeeding companies make use of artificial intelligence to upgrade themselves, then why not you too implement it! With our AI-enabled tool, you can improve oracle database performance easily and in less time. Even, in one of our tools, the source code of the program will remain untouched, yet the problem will be solved. The tools really don’t require the user’s involvement in fixing the queries. Therefore, if you are searching for any such product, then browse our products and get the one that suits you the best.

Tosska Technologies aims at helping users to smooth out the problem with the new and advanced technologies in the market. You should surely give it a try; we assure you will love the product offered by us.

Don’t Overlook Oracle Database and SQL Performance: Here’s why

oracle database and sql

Being a DBA is not always a fun job, thanks to certain time-consuming tasks that it entails. One of these is to ensure optimal Oracle database and SQL performance. Typically, it is done by spending a lot of time tuning the long list of SQL statements and software code in order to improve efficiency and enhance access. However, SQL is just one aspect that is related to the performance of database systems.  

Database Administrators also need to invest their time in enhancing the design, physical structure, and specifications of the database objects. These objects are the tables, indices, and the information stored over several files. In the case of data inefficiency, it becomes necessary to observe and modify the actual construction and composition of database objects on a consistent basis. This is because any amount of SQL performance tuning is bound to fall short in a database that is improperly organized or poorly constructed.  

Optimizing Oracle Database and SQL: 5 Important Techniques 

The DBA has to be aware of all the specifications that the database management systems consist of as this knowledge will enable them to use the right techniques to optimize database constructs.

A majority of the most popular DBMSs are compatible with all the methods we have mentioned below, though they may be used differently depending on the database. Let’s take a look:

  1. Indexing: An essential aspect of the Oracle database and SQL performance tuning process is by selecting the right indices and alternatives in order to enable efficient queries. 
  2. Clustering: This involves implementing the physical pattern of data on the disk so that it is clustered on the same page whenever accessed in a particular order. 
  3. Compressing: Data is compressed by decreasing storage requirements, thereby allowing more of it to be stored in a smaller amount of space. This also reduces storage expenses and enhances access if you can add a larger number of rows per page.
  4. Freeing Up Space: Assigning extra room for data growth allows new data to be added to its table easily without leaving the table disorganized.
  5. Partitioning: This entails the segregation of one database table into various sections that are saved in several files. This can be done in multiple ways; by partitioning one file in the same computer, partitioning using shared-disk clustering or by shared-nothing partitioning, depending on the DBMS in question.
  6. File Organizing and Placement: Allocating data from both – database systems and data files – to the correct places is a big step in organizing data and improving Oracle and SQL database performance.
  7. Checking the Page Size: The size of the block or the page determines how efficiently data can be stored and accessed, which is why it is vital to use the suitable page size. The smaller the size of the page, the fewer rows per page, which increases sequential data access requirements.  
  8. Interleaving: Merging all the data from several tables in a sequence into a file helps enhance join performance. However, this method seems to have become less popular than it used to be.
  9. Reorganizing Database Objects: Eliminating the defects from the database by reorganizing and arranging database objects is a well-used technique in SQL performance tuning. In fact, it enormously increases performance, especially if the data was previously fragmented, disorganized or scattered in some way.
  10. Denormalization: This method is considered as a last resort attempt in case the database is unable to perform optimally with a completely normalized implementation. This is because it differs from the logical design. 

All of these techniques are useful and should be considered when the DBA creates a plan for tuning and monitoring the database. Each aspect may not necessarily be applicable to every database object but it must be analyzed for its applicability all the same. Moreover, techniques that are not applicable during initial implementation may turn out to be useful as the application undergoes changes over time in various aspects like data volume, usage, and database characteristics.

How to tune Oracle application packages’ SQL without touching source code

download free sql server
Introduction

Application package software is a collection of software programs that is developed for the purpose of being licensed to third-party organizations. Although

a package software may be tailored for a user’s specific needs through parameters or tables, the software itself is not developed specifically for an organization. So, users do not own the source code and have no way to modify the embedded SQL statements for performance tuning purpose. There are a lot of application packages built on Oracle RDBMS such as Siebel, PeopleSoft JD Edwards, SAP and so on. In order to help application packages’ users, Oracle provides some features for helping users to tune their SQL statements without the need to change their source code.

SQL profile

It is a profile generated by Oracle SQL Tuning Advisor. A SQL profile contains corrections for wrongly estimated statistics, auxiliary information. Therefore, SQL profile just guides the optimizer to a better plan, but they do not guarantee the same plan each time the statement is parsed. For certain SQL statements, no matter how good the statistics are corrected, Oracle SQL optimizer is still not able to generate a better plan in specific environments. For these kinds of SQL statements, human intervention is necessary, but SQL profile is not a convenient tool for developers to force Oracle to pick up a new plan without changing the program source code.

SQL plan baselines and stored outlines

Due to the Oracle environment changes or Oracle database version upgrade, it might target Oracle SQL optimizer to generate new plans for certain SQL statements. If it is not good, and we need something to preserve the old plans for the new environment. To achieve SQL plan stability, stored outlines was the major tool in earlier releases of Oracle Database. This feature is still supported in Oracle Database 11g; however, it might be depreciated in the future releases and replaced by SQL plan management. The mechanism of SQL Plan Baselines is to preserve the performance of specified SQL statements, regardless of changes in the database environment or release upgrade. Furthermore, create Plan Baselines manually for a SQL statement is possible, and this technique can help developers to guide Oracle SQL optimizer to generate a specific plan for a bad performance SQL statement. So, when Oracle SQL optimizer receive the same SQL statement next time, a better performance plan will be composed according to the new plan baselines stored in database. There is no need to change the SQL syntax in source programs.
For example, if you want to tune a SQL with execution plan-A that is currently used by Oracle SQL optimizer in your database, and you want to tune the SQL with Hints to make Oracle SQL optimizer to generate a new execution plan-B. What you have to do is to execute the tuned SQL with new Hints and use the following method provided by Oracle:

Execute the tuned SQL with Hints and plan B cached in SGA.

SET SERVEROUTPUT ON
DECLARE
    My_Plan  PLS_INTEGER;
BEGIN
     My_Plan := DBMS_SPM.load_plans_from_cursor_cache(
              sql_id          => 'Plan-B SQL_ID',
              plan_hash_value => 'Plan-B plan_hash_value’,
              sql_handle      => 'Original SQL’s sql_handle');
      DBMS_OUTPUT.put_line('Plan Loaded=> ' || My_plan);
END;

To enable the use of the tuned plan, manually alter the tuned plan to a fixed plan by setting its FIXED attribute to YES.
To enable the use of SQL plan baselines, make sure the OPTIMIZER_USE_SQL_PLAN_BASELINES initialization parameter is set to TRUE.

Weaknesses of using SQL Plan baselines for SQL tuning

As the SQL plan baselines was designed to preserve the performance of SQL statements such as after the following environment changes:

  • New optimizer version
  • Changes to optimizer statistics and optimizer parameters
  • Changes to schema and metadata definitions
  • Changes to system settings
  • SQL profile creating

You can see that it is not designed for the purpose of manual SQL tuning. There are also some additional limitations such as Parallel Hints is not supported by SQL Plan Baselines, you cannot load a Plan-B with Parallel Hints applied your SQL with bad performance of original Plan-A. Parallel Hints sometimes are very important for a better plan generation by Oracle SQL optimizer.

SQL Patches

SQL Patches is part of the features provided by SQL Repair Advisor which is used to fix a SQL statement’s critical failures such as returning wrong result. The SQL Repair Advisor analyzes the problematic statement and in many cases recommends a SQL patch to repair the statement. The SQL patch is to influence the Oracle SQL optimizer to choose an alternate execution plan for future executions, instead of using the original problematic execution plan. There is a public API call to create SQL patches manually provided by Oracle Database 12c Release 2 onwards. The DBMS_SQLDIAG.CREATE_SQL_PATCH package can help users to create a SQL Patch for specific SQL statement for SQL tuning purpose. You can change a bad performance SQL statement’s execution plan without the need to modify the program source code as the following example:

DECLARE
    Patch_name  VARCHAR2(32767);
BEGIN
    Patch_name := SYS.DBMS_SQLDIAG.create_sql_patch(
        sql_text  => 'SELECT *
                      FROM   employees
                      WHERE  emps_dept IN
                     (SELECT dpts_id
                      FROM   departments
                      WHERE  dpts_avg_salary <200000)', hint_text => 'INDEX(@SEL$1 EMPLOYEES) INDEX(@SEL$2 DEPARTMENTS)',
        name      => 'my_sql_patch_name');
END;

If your database version is before Oracle database 12c Release 2, you must use this package DBMS_SQLDIAG_INTERNAL.i_create_patch instead. Both SQL text and SQL ID is able to be used for SQL hints injection. The injected hints for your SQL should be placed in hint_text input parameter. There is only one line of Hints text you can use for a SQL and there is no way to define your own query block name for any subqueries’ block. So, if your SQL has multiple subqueries and you want to instruct Oracle to do something in subqueries’ blocks, you must use Oracle default query block names in your injected hints text.
hint_text => ‘ INDEX(@SEL$1 EMPLOYEES) INDEX(@SEL$2 DEPARTMENTS) ‘
This hints text in the above example shows that @SEL$1 and @SEL$2 are default query block names provided by Oracle in the execution plan of the SQL. The Hints tells Oracle use index search for EMPLOYEES table in query block @SEL$1 and also use index search for DEPARTMENTS in query block @SEL$2.

Pros and cons of using SQL Patches to tune SQL

SQL Patches is more flexible to accept hints instructions without SQL Plan Baselines’ limitations, complex hints with parallel operations are normally accepted by SQL patches. There is no additional maintenance effort to tell Oracle to use the SQL Patches after it is created. Oracle will use the stored hints to optimize any SQL with the same SQL ID or SQL Text and generate a better performance execution plan. Furthermore, you can also use SQL Patches to disable a SQL with a destructive hints already written in a package application or even use it to control a bind-aware SQL execution behavior.

As the injected hints text must be placed in one text line and using default query block name only, manually compose a desire Hints to improve a SQL statement will be a difficult task for most SQL developers especially for complex SQL statements with many subqueries.

A tool to automatically create Hints and SQL Patches

There is only one tool in the market so far that is able to generate a better hints and create SQL Patch in a fully automatic way.
Tosska SQL Tuning Expert Pro is a tool for users to improve SQL performance without touching their program source code. Users can deploy different performance query plans for various sizes of production databases without the effort of keeping multiple versions of the program source, and it is especially suitable for package application users who don’t own the source code of their applications. The tool will try most useful hints combinations to tune your bad performance SQL statement, the best Hints combination SQL performance will be benchmarking side by side with the original SQL. Users will get the exact performance improvement without any guesswork or uncertain cost assessment only.

You can visit our website for product details
https://tosska.com/tosska-sql-tuning-expert-pro-tse-pro-for-oracle/