Showing posts with label dba tuning. Show all posts
Showing posts with label dba tuning. Show all posts

Wednesday, 18 May 2022

What do You Mean by Oracle Performance Tuning?

oracle performance tuning

Performance tuning is a process in which we fine-tune a database to improve its operational performance. This process includes working on performance tuning a SQL query and query execution plans so that queries can be completed more efficiently.

A simple-effective approach to oracle performance tuning tips

Performance tuning an Oracle database is a complex job, as it depends on a lot of factors. To make things simple to understand we will apply a simple approach like performance tune SQL query.


Here we begin:


 Identify queries that consume resources: Identify queries that take more time and consume more system resources. Oracle database monitoring tools like Oracle SQL Analyze are of great help in situations like these. These tools do their work by identifying resource-intensive SQL statements. Just tune those statements and achieve your feat.

 

    Minimize workload with index use: There are cases when the same query comes up in different ways. So write a code that minimizes workload to the bare minimum. To avoid a large workload on a database use indexing to access a small set of rows instead of processing the entire database in one go. Use indexing in scenarios where a column is regularly queried.

 

  Use stateful connections with applications: There are instances when the database performs poorly not because of code, but because of frequent disconnection between the application and the database. If there is an issue in application configuration then it would connect to the database to access a table, followed by a disconnection immediately after getting its hands on the required information.

 

Performance Tune Sql Query

 Avoid connection drops and save system resources: This frequent disconnection immediately post accessing the table is often a reason behind the database's poor performance. So, try to avoid any connection drop at all times, so that the application is connected with the database at all times. This approach will go a long way in avoiding the wastage of system resources every time there is an interaction between the application and the database.

 

 Store and collect optimizer statistics: Optimizer statistics is data that describes a database and its objects. A database uses these statistics to choose the best execution plan for SQL statements. Collecting and storing optimizer statistics regularly is crucial to maintaining database efficiency.

 

  Accuracy in the database at all times: This approach ensures that the database has accurate information on table contents all the time. In case the data is inaccurate, then the database will go for a poor execution plan which will affect the end-users database experience. Oracle databases have an inbuilt ability to collect optimizer statistics on their own or you can do so manually with the help of the DBMS_STATS package.


Conclusion

Yes, Oracle is an excellent data management tool. But even the best tools fail to deliver when not managed well on the ground. So, with the help of oracle performance tuning tips shared above along with the job of performance tune SQL query it will deliver up to user expectations.

Oracle Performance Tuning Tips

 

Thursday, 30 December 2021

Oracle Database Performance Tuning Tips for Great Results


A lot of clients encounter performance issues while using data warehouse programs. In this post, we will discuss some important methods that will help users improve results in Oracle database performance tuning by examining and enhancing the performance of Oracle Analytics reports.

The Best Ways to Ensure Optimal Oracle Database Performance


Take a look at the tips and tricks for better Oracle report analysis explained below:

 

  1. Query Log Assessment: This involves the following steps-

  Check the time you spend in your Oracle database and SQL and compare it to the amount of time a statement takes in Oracle Analytics. In other words, you’re comparing the statement duration and response time. Typically, the former takes no more than a few seconds.

    Examine the individual steps in Oracle Analytics in case the response time takes more than a few seconds. You will need log level five for this.

 

  1. Go through the physical Structured Query Language

   Take a look at all the tables being involved in the statement. Is every single one of them important for the query? You will also have to check whether there are any tables that are joined but don’t have filters other than the join condition, nor are they a part of the SELECT clause.

    Find out the number of physical statements and sub-statements that are being generated in the Oracle database. To put it simply, you need to identify the number of times the statement reads a fact table. Under ideal conditions, the statement reads only one fact table and it does so only once, so it is important to know when there are multiple reads and the reason behind them so you can eliminate some of the extra reads.

You can do this by locating excluded columns, aggregation rules that are non-additive, such as those with concatenated count clauses, selection measures, reports with sub-statements, etc.

   Look out for external joins: if you find any, locate their origins and find out ways to get rid of as many as possible (you may have to change the design).

 


  1. Assess the execution plan for the root cause of the performance-related problem: - Follow this tip in case the steps you took during Oracle database performance tuning didn’t prove sufficient. You may enlist the support of your DBA for this purpose. These are the 4 main methods to boost performance in this situation-

     Work on the data access path by adding indexes to decrease IO volume.

  Lower the IO volume by decreasing how much data is read. For instance, you may go through the filters or the architecture of the data model.

      Raise the thread quantity for reading larger tables (parallelism).

      Make other changes to boost the IO rate, such as infrastructure modifications, in-memory database, etc.

  1. Analyze the data model and take the following measures to decrease the data read volume: -

      Generate aggregate tables

      Use an Oracle query optimizer tool wherever required.

      Apply fragmentation: You might find this example useful- in case users consistently select data from the current month or year, you can divide the data into two tables: archive and present. Partitioning is also an option in the case of the Oracle database.

      Implement denormalization. You will be able to lower the join quantity.

      You can also decrease column quantity by dividing tables.

 

To Sum Up


A large number of performance problems occur due to poor design which is why they require Oracle database performance tuning. This is true in the case of Oracle Analytics as well since inadequate design can lead to the creation of sub-par SQL statements.

Making changes to the design will not only optimize the SQL statements created by Oracle Analytics but will also affect the overall performance of the database. This will be because of the more efficient use of resources. 




Sunday, 31 October 2021

The Best Ways to Ensure Proper PL SQL Performance Tuning

 


There are many things you can do as a database professional to ensure your PL SQL code runs as it should. Therefore, in this article, we will talk about some good coding practices and offer advice regarding PL SQLperformance tuning.  

The tips presented in this post are extremely reliable; in fact, top experts and experienced database technicians recommend them. They have been aimed at enhancing the execution time and getting the code to run optimally. 

The code you have to tune has to take the least time to run. This is particularly important when the statement consists of several rows and the function is present in a SELECT clause. In such cases, the DBA first analyzes the nature of the function and then checks to see whether the database views will prove more productive. 

The goal behind any kind of optimization, including Oracle SQL performance tuning and optimization, is to prevent users from facing any issues or wait times when using the database. 

In case the function mentioned above has a reference in a WHERE clause, it is important to look into it further. This will help the DBA determine if a function-based index will help run the SQL faster. 

It is also essential to carry out proper coding methods and practices when it comes to functions. That is because functions work best when they only contain a single RETURN clause in the regular (Begin) area present in the code. They can make use of purity features to reduce or eliminate side effects. 

The next thing to consider is tuning every SQL call because SQL, when getting executed from PL/SQL, results in some extra overhead, known as a context switch. The SQL and its output find their source in the SQL engine which is why PL/SQL must request for every row from SQL. 

Several experts are willing to educate newcomers for PL SQLperformance tuning and it certainly helps in this regard as well. They also mention bind variables to boost cursor reuse and decrease hard parsing as much as possible. However, experienced professionals advise against using them too much as they might cause other issues in the execution plan. 

Another element that steadily reduces performance is the bulk processing of information. This is especially true if IN OUT or OUT parameters come into play. For this, it is better to use the NOCOPY alternative that allows the database to pass pointers rather than the entire information itself. That said, the best thing to do in these instances is to simply place all the routines in one package so nothing has to be passed!

Collections have also greatly improved in Oracle.  For instance, the BULK COLLECT and FORALL features have become much quicker and have now proven to be the answer to row-at-a-time processing. Moreover, Oracle prefers hitting rows that don’t contain null values, and certain methods, such as the FIRST, the NEXT, and the LAST method, tend to skip null rows. 

DBAs recommend another tip: to keep loop code as short as possible. Combined with good coding methods and single result set processing, this strategy is extremely helpful in Oracle SQL performance tuning and optimization. Also, developers should try not to use EXIT while they are inside the FOR or WHILE loops. 

A majority of experts consider this to be poor coding because it mostly results in unexpected behaviour. The better thing to do is to make use of a single EXIT command and leave the loops simple. It doesn’t only make coding and executing easier, but it also simplifies maintenance in the long run. 

Want to use the FOR loop? You can do it, but avoid declaring the FOR loop subscript. In case it already has a declaration that isn’t a PLS_INTEGER, Oracle will find it necessary to turn it into this format before it executes every single iteration of the loop. For instance, declaring the “i” in “FOR i IN…” will waste time in conversion. 

The key to ensuring lasting results in SQL performance tuning is to use recent coding technologies as they are introduced. It is useful because it will improve the consistency of your code in conjunction with coding practices that exist in other languages. 

Additionally, it becomes more convenient for the Database Administrator to modify the code when they know other experts follow the same practices during code maintenance. For example, all C programming languages have Boolean logic in common. This is why it’s vital for database professionals to conform to certain practices and techniques that will also ensure consistent performance throughout various databases.



Thursday, 29 July 2021

How an Execution Plan is Picked by SQL Optimizer for SQL Server


The Query Optimizer for SQL Server is designed to be cost-based. This means it assesses several execution plans and estimates each one’s cost before picking the plan that seems the most cost-effective.

Since this tool is unable to take every single plan into consideration, it ends up performing a balancing act by taking into account the costs involved in both - locating possible plans and implementing them. In this blog, we will look at the SQL optimizer for SQL Server and the steps involved in its process of identifying the best execution plan.


Oracle SQL Query Execution Plan Picking Process

The SQL Server Database Engine is made of two major parts - the Relational Engine (Query Processor) and the Storage Engine. The Relational Engine is responsible for all the statements sent to the SQL Server. It is tasked with creating a plan that ensures optimal execution to deliver the best results.

The Storage Engine, on the other hand, is in charge of optimally reading data from both memory and disk while preserving data integrity. Statements are sent to SQL Server through SQL language(s). SQL only specifies what type of data needs to be fetched and not the methods that can be used for this purpose. Neither does it present any of the algorithms that can be applied to process the request.



Therefore, the first step the relational engine takes when it gets an Oracle SQL query is devising a plan as fast as it can. The plan must mention the most favorable or even efficient method to run said statement. The next thing to do is to use that plan to execute the statement.

All the steps are assigned to individual parts inside the query processor. Inside, it is the job of the Query Optimizer to design a plan, which it submits to the Execution Engine to execute to receive results accordingly.

Steps Involved in Creating an Execution Plan to Carry Out a Query

Considering the SQL optimizer for SQL Server, it takes a certain number of steps before the Relational Engine can provide the Execution Engine with the best or an efficient-enough execution plan. These steps have been mentioned here:

       Parsing

       Binding

       Optimizing the Query

       Running it

 


  1. Parsing & binding - The statement, supposing it is correct, undergoes the parsing and binding process. A valid query has its output in the form of a logical tree that has nodes symbolizing each logical operation being mentioned in the statement. For example, performing an inner join or a read action in the specific table will both be represented as separate nodes in the logical tree.
  2. Query Optimization - The logical tree helps in the query optimization procedure that is made up of the following steps -

    1. Creating Potential Execution Plans – With the help of the logical tree, the Relational Engine or the Query Optimizer generates more than one potential method (execution plan) to run the query without incurring excessive costs. An Execution plan is essentially a bundle of physical tasks that must be carried out in order to provide the expected results as represented by the logical tree. These operations are part of the Oracle SQL query and include tasks such as nested loop joins and index seeks.
    2. Evaluating the Cost of Every Plan – Even though the Relational Engine doesn’t create each and every execution plan that can be generated, it does examine the expenses incurred by every plan it actually creates, in terms of cost and resources. Among these, it selects the plan whose expenses are evaluated and found to be the lowest. This plan is then relayed to the Execution Engine.
  1. Running the Query and Caching the Plan – The statement is run as per the plan that has been selected and sent to the Execution Engine by the Query Optimizer. This plan can be saved in a designated area known as the plan cache, which is located in memory.

 


What do You Mean by Oracle Performance Tuning?

Performance tuning is a process in which we fine-tune a database to improve its operational performance. This process includes working on pe...