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