Showing posts with label improve MySQL database performance. Show all posts
Showing posts with label improve MySQL database performance. 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

 

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.



Friday, 26 March 2021

Improve Performance of SQL Query by Avoiding Swapping



Every so often, you may have MySQL or another application take up excessive amounts of memory on the operating system or the box. As a result, the OS may behave abnormally - such anomalous behavior is often visible in the form of increased memory utilization for cache and forcing swapping among applications. 

In other words, such unrestrained usage of memory inevitably leads to swapping and performance-related issues. The intensity of those issues is another cause for concern, as swapping is likely to affect your performance harder than the average IO, leading you to search for ways to improve performance of SQL query, even MySQL altogether.


Handle Swapping Before You Improve MySQL Performance of SQL Query

In this post, we’re going to find three reasons why swapping creates much more significant problems for performance than a normal IO.


Reason 1 - Multiplication of IO Due to Cache

In comparison to the presence of reduced cache, IO will be multiplied once cache in the swap file increases. If the page inside the cache gets swapped, the user will need to locate space in order to swap in the page, meaning other pages will have to be swapped out.

Such a task needs to be carried out, even if it is completed in the background. On the other hand, flushing or getting rid of the page will lead to additional IO, thereby worsening the situation by slowing performance tuning in SQL Oracle.



Reason 2 - Getting the Algorithms all Mixed Up

There are certain algorithms running internally that are designed for data inside the memory. If they begin handling data stored on disk, their productivity gets impacted.  That’s why a different combination of algorithms is used to deal with disk data, and these are optimized to restrict the quantity of IOs or turn them into something more sequential.


Reason 3 - Increased Latches or Locks

Interruptions within the internal operations of a database are bad enough without swapping wreaking havoc upon concurrent processing like multi-client or CPU. Bear in mind that a database latch or lock is generally created to work for extremely short time frames. How short? Well, as short as you can possibly keep them.

That’s because the system will surely scale better when fewer exclusive locks are occupying the execution time thread. So, you must absolutely avoid any critical locks during disk IO because they take a considerable amount of time as is.


In Conclusion

Users are advised to configure the system in a manner that keeps any form of swapping activity away while normal operations are being carried out, to ultimately help improve MySQL database performance.

Additionally, make sure you are able to justify every instance that uses a swap file. Instances, where it is acceptable, include unanticipated spikes in memory utilization, where slower performance may be preferable over none. 






 

 

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...