Showing posts with label MySQL SQL performance tuning. Show all posts
Showing posts with label MySQL SQL performance tuning. Show all posts

Tuesday, 25 January 2022

MySQL database and SQL: Working with Table Fragmentation

You may already know that a table that only undergoes a whole lot of insert operations doesn’t face fragmentation in MySQL database and SQL. Generally, this takes place through an update or a delete operation.

 

Such tasks leave behind gaps among the information that remains in the table and that is the true cause of table fragmentation. Moreover, the database doesn’t immediately replace these spaces that non-insert DML commands liberate.

In this blog, we will discuss how the database management system handles this space for the tables.


MySQL SQL Performance Tuning: Managing Table Fragmentation

In some cases, row storage isn’t contiguous or the rows are divided across multiple blocks. Both of these negatively impact the database, so you will need MySQL SQL performance tuning to reduce the requirement of additional block accesses.

Keep in mind that table fragmentation and file fragmentation are two distinct occurrences. Table fragmentation involves the application of many Data Manipulation Language commands. This is because the resulting free space does not get released by the DML from the table, except if it is under the High-Water Mark (HWM).

High Water Mark is a measure of that DBMSs occupied blocks. Those that lie under the HWM may or may not have data at the moment but they have held it at least once. The database is aware that blocks over this indicator have never contained data. It is why it only reads those that reach up to the HWM during a complete table scan. This value can be reset by a DDL query.

 


Why Table Reorganization Can Help MySQL Database and SQL

This particular task helps deal with three major problems with MySQL Database and SQL:

 

●      Too many chained or migrated rows

●      Sluggish table response time

●      Wasted old space due to non-uniform table growth


There are certain ways to locate a majority of fragmented tables. Look for tables that have a sizable difference in their expected and actual sizes. Such differences usually occur thanks to table fragmentation or old stats that haven’t gone through updates.

If you want to determine and eliminate table fragmentation, you may follow the steps explained briefly below:

  1. Bring together important table stats, such as the actual size and stats size. These will help you calculate the exact difference between the two and help you identify the presence of fragmentation. You will require updated stats in dba_tables for this purpose. To verify whether the stats are new, you can go through the last_analyzed value or try collecting table stats.
  2. Find out the current table size- if it is smaller than its older size, you can tell it has undergone table fragmentation.
  3. Other signs you can look for in the table include the overall size of the table (with fragmentation), what size you may expect in the absence of fragmentation, and the percentage size the DBA may regain once fragmentation is removed. You will require the table and schema names for this.


Final Thoughts

You can still gain performance-related advantages from a large number of fragmented tables with the help of the steps mentioned above.

These will enable you to collect all the necessary statistics that will inform the optimizer on how to build the most favorable execution plan. The plan will ensure MySQL SQL performance tuning for better results during statement execution. 


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.



Tuesday, 24 August 2021

Oracle Database and SQL Cloud Migration: 7 Things to Know



In case you are planning to migrate your Oracle EBS to the cloud, there are certain factors you must consider before making your decision. This is because of multiple reasons, one of which is the rapid implementation of cloud technology, especially in the last two decades.

However, some databases seem easier to adapt to the cloud than other databases and applications - others don’t need to. Oracle EBS, in particular, is an extremely robust suite containing 200+ apps that come with several custom opportunities. Here, we will mention the most important Oracle database and SQL areas to go through before you begin migrating it to the cloud.

7 Key Factors to Consider for Cloud Migration of Oracle Database and SQL

If you want to improve the functionality of your database further by adding cloud availability and scalability to it, take a look at the things you must take into account before you do.

1. Data Interface

This is the first most important aspect to take care of during your cloud migration preparation. You must keep an eye on your interface jobs as they will help you decide multiple things later and make sure the process isn’t too complicated.

Go over each interface job along with the transaction volume statistics and make sure the job executes as per expectations while maintaining connectivity. Doing this will help you during Oracle database performance tuning later.

 

2. Data Migration Approach

Go through your data migration plan to check the length of cutover time (it should be as low as possible). Your choice of cloud platform will decide how much potential downtime you will have to face in the future.

This is important to know because everyone knows downtime can have a significant impact on user performance and satisfaction. Find out the permitted downtime for cutover as you will know the time you have to work with and switch your approach accordingly.

 

3. Existing Storage Option

Review the present storage situation and IOPS requirements for your Oracle database and SQL. This will limit your search and help you find cloud platforms that will help you meet your business specifications.

 

4. Testing Approach

Save yourself from getting unwelcome surprises after the migration is complete by assessing your testing strategy. Experts suggest doing it from a UAT (User Acceptance Testing) perspective during the POC (Proof Of Concept) phase.

Make sure your testing strategy considers depletion and load testing situations and utilize a production-like runtime environment. Monitor the jobs that are running and completing smoothly - check their runtimes as well as the volume details.

 

Although you get varying options with each cloud platform, the ones they have in common - which you have to review - are the following:

 

●     The size of the virtual machine

●     Types and specifications of disks

●     Areas

●     Network performance

 

5. Storage Consumption

Assess the storage footprint of the database and all the areas you can decrease expenses on the cloud. In case your present solution has compression and duplicate-removal mechanisms, your data is likely to grow faster once it transfers to the cloud. This may complicate things for Oracle database performance tuning in the future.

Additionally, you’ll have to consider the storage use and expense for both production and mon-production purposes on premises. Consider the general effects and changes your chosen cloud settings and the possible restrictions related to storage will bring on your existing database operations.

 

6. Application Variants & Certification Classification

Aside from the certifications for Oracle EBS and its version, it is important to verify the version and certifications of the other applications you will use including the database, Java, browser, operating system, and others to make sure everything will work smoothly in the cloud. Set some time aside for upgrades before migration.

 

7. Arrangements for Data Backup and Analysis in the Long Term

Assess and understand all the backup options available for your chosen cloud platform and evaluate all the clone processes and SLAs with everyone involved so everyone is aware of the operational requirements. You will also have to analyze your monitoring tools and merging with the ITSM to figure out the changes your day-to-day database and monitoring functions will undergo after the shift to the cloud platform. 

Sunday, 28 February 2021

Oracle Database and SQL: A Brief Introduction to Oracle

 

Oracle is a multi-model RDBMS or a Relational Database Management System. It was essentially created for grid computing in enterprises as well as data warehousing.

Oracle is among the primary choices for companies looking for economical solutions for data handling and the applications they use. In fact, Oracle database and SQL is among the most common combinations used in enterprises.

Features of Oracle Database and SQL

Oracle and SQL are two words often referred to at the same time. So, what is the difference between Oracle and SQL? Simply put, Oracle is the Relational database management system, whereas SQL or Structured Query Language is the compatible query language used to interact with the database.

Take a look at some of the prominent features of Oracle:

 

●       Flexibility and Productivity: Oracle offers functions such as portability and Real Application Clustering that result in a greater ability to adjust as per the organization’s usage. For databases involving several users, Oracle also enables data consistency and the advantage of carrying out tasks from multiple users at the same time.

 

●       Accessibility: Many of its applications operate instantaneously, therefore needing constant data accessibility. Computing environments that provide high performance are also designed to enable data availability throughout the day. Data can be accessed even when there are scheduled or unexpected downtimes and lapses.

 

●       Backup and Retrieval: Oracle has been created with data loss in mind, which is why it has several recovery features to help retrieve lost data in nearly every type of data failure. If an unfavourable event leads to failure, the database will have to be retrieved as quickly as you can to ensure high availability.

In Oracle, all those parts of data that have not been affected by the issue are made accessible immediately, while the affected ones are being retrieved.

 

●       Data Protection: This is one of the most important aspects of any database management system. Oracle offers methods to secure data access and manage its utilization. Enforcing authorization and modifying user actions can keep the information safe from unauthorized access and provide access to only the right users.

What is the Oracle Database Used For? Know its Importance

Oracle was created by one of the oldest companies to offer DBMSs, an organization with a constant focus on the fulfillment of the data-based requirements of other organizations. This is why its products come packed with updated features to meet the growing needs and expectations of database administrators.

Now that we’ve discussed some of the most important features of Oracle, let’s know-how they make Oracle an option worth choosing over its competitors. Let’s take a look at some of its major perks:

 

●       Excellent Performance: It has various mechanisms and concepts that ensure high performance. Users can conduct performance tuning in their organizational database to further improve the speed and efficiency of data retrieval and manipulation.

●       Several Databases: This RDBMS facilitates the management of several database instances on the same server. This is done through the Instance Caging method that handles CPU resources being allocated to the server operating the database instances. This technique works alongside the database resource manager to take care of numerous services across multiple instances as well.

●       Real Application Clusters: The use of Real Application Clusters guarantees a robust system with data that is always accessible. Here are some major benefits of an RDBMS with RAC over conventional databases:

●       Adjusts the the scale of the database through several instances

●       Maintains a balance of loads

●       Reduces data redundancy and improves availability

●       Adaptable to fluctuating processing capacities

●       Restoration in the Event of Failure: The recovery manager (RMAN) is designed to recover and retrieve database files when the database is affected by a power shortage or another type of impediment. It works in multiple ways: online, by archiving backups and performing regular backups. Users also use other tools that work excellently for Oracle, such as SQL* PLUS (which is a type of user-managed recovery).

●       PL/SQL: Oracle database and SQL support the PL/SQL extension for methodological programming.


To Conclude

Oracle is certainly one of the most powerful RDBMSs that caters to the requirements of applications at both small as well as enterprise levels. This database server management software contains all the functions needed to assist and accommodate modern applications, which is why it is widely used even today.

 

Friday, 29 January 2021

Optimization of SQL Queries: Cons of Multiple Storage Engines



Among the big advantages advertised for MySQL includes support for several storage engines. This seems like an excellent advantage at first glance because users gain the advantage of using the same high-level SQL interface, enabling them to save their information in numerous ways.   

Though it may seem quite useful, this advantage comes at a high expense in terms of performance, growth, and operational intricacy. In this post, we will discuss just a few challenges of this particular feature.  

Cons of Multiple Storage Engines in Oracle\MySQL Databases 

Consider the following setbacks due to the support provided for multiple storage engines in Oracle queries - 



  • Conversions – Every storage engine contains its unique format for storing data, so MySQL performance tuning requires plenty of copying and conversions when it needs to access the information. This has a substantial impact on performance in comparison with a “zero-copy” design, where users may stream information from memory when it can be accommodated there. Optimizer and Execution Storage engines are not created equal especially if you look at In-Memory storage engines vs Distributed ones. 


  • Managing many different instances in query optimizer - Certain tasks and cases like clustering by The primary key in Innodb, the memory-based characteristics of the MEMORY storage engine and the distributed nature of NDB tend to get more complicated than necessary. This is due to the need to cater to several use cases that keep MySQL from exploiting the proper performance potential of either of the storage engines. 


  • Integration and Synchronization - The upper-most level at the MySQL side that includes .frm and binary log files require synchronization with storage engine transactions. This, in turn, takes up significant performance overhead and gets rather complicated. Also, despite MySQL doing numerous fsync() calls for each transaction commit just to remain on the safe side, many tasks still aren’t completely safe. For example, .frm files can be retrieved from the internal data dictionary in case of a crash at an inopportune moment. 



  • Transaction Assistance - There are several combinations of locks that users need to manage on higher levels and inside storage engines. They also have to deal with varying locking strategies owned by storage engines, which can lead to plenty of surprises if they choose to venture into the cross storage engine transactions.


  • Backup - Backing up data across storage engines can be frustrating due to their differences. While some of these storage engines are distributed, others use the memory, which means even versatile approaches such as LVM backup could fail in some situations.  

Query Optimization & Multiple Storage Engines - Final Thoughts

It is interesting to note that a single storage engine is more than sufficient for over ninety-five percent of applications that use SQL tuning for Oracle. Moreover, most users already prefer to use only one storage engine instead of mixing multiple of them because of the hindrances mentioned above. 

At the same time, this doesn’t mean users should give up flexibility altogether. For instance, administrators can enable InnoDB tables that don’t log changes, which will increase the rate of update operations. They may also lock those tables in memory to make sure the in-memory performance doesn’t get unpredictable.











Monday, 18 January 2021

Delayed Flushing & Its Role in MySQL SQL Performance Tuning


Fact: delayed flushing may actually lead to reduced load. It may sound hard to believe, but if you ask an expert about the reasons behind systems delaying flushing changes to durable storage, you might get one or both of these answers:

  1. In order to complete the task at a more convenient time
  2. To have less work overall

In this post, we will examine the second reason and whether it helps MySQL SQL performance tuning.


Higher Peak & Average IO Rates with Adaptive Flush

The total number of I/O operations performed definitely improves with adaptive flushing. What happens here is, the workload gets smoothed out by adaptive flushing, which results in more work getting done.

Why does this happen? As you might recall, InnoDB works on 16kb pages at a time. Suppose one of the users manipulates the data of one of the rows. If InnoDB flushes constantly, it will flush the whole 16kb page right then. Just after this flush, a different row undergoes changes on the same page, which causes one more page flush.

If the first flush were to be delayed, the two flushes would be performed as a single flush. Delaying a flush to perform along with other flushes as one flush is known as write combining in MySQL database and SQL.

In certain workloads, the same rows may end up getting updated numerous times, which is where delaying and allowing write combining may dramatically reduce the quantity of I/O operations.

Does Recovery Time Affect this Result?

Some of us might think that recovery time is a significant factor for MySQL SQL performance tuning, and that enabling this option is not really necessary if that isn’t the case. However, it actually depends on the workload, and if each flush takes up a resource that is also required by another task.

If the data is able to fit in the buffer pool, and no read operations are taking place at that moment - which means the disk isn’t required for any other operations - the disk would only be in use for write operations. Also, if everything is ready at the OS and RAID controller layers, a read operation won’t be needed for a write either, helping Oracle database performance tuning.

An important point to remember is that other than a mutex contention inside MySQL or InnoDB, write operations typically run in the background - so they don’t block foreground tasks.



 

 

Monday, 14 September 2020

Multiple Clustering Indexes & MySQL SQL Performance Tuning

A clustering index is a different type of index that contains the entire data for the rows. Users gain quicker access to rows through clustered indexes because all of the data is on the page reached through the index search.

For bigger tables, the clustered index decreases the number of disk operations, especially in the case of companies that use the index record to save row data on different pages. If you understand the workings of clustered indexes, you can improve MySQL SQL performance tuning as well, which is why we are discussing them in this blog. 



Improving MySQL SQL Performance Tuning: Understanding How Clustered Indexes Work

A majority of storage engines support a maximum of one clustered index per table. While some do not support them at all, others only enable the primary key to become a clustered index. However, functionality and grammar syntax have evolved throughout these years, so users can enhance MySQL SQL performance tuning with the help of such means.

So, how do clustering keys operate? A clustering index basically stores a copy of the whole row and data is typically clustered with a primary key. Therefore, lookups are not considered in the primary index, since a clustering index covers all the queries. In a way, it is the implementing of a table in a different set up.


Clustering indexes have significantly shorter key lengths which is advantageous in terms of performance - they allow quicker insertions as compared to those in covering indexes. Non-MySQL databases also support the inclusion of monkey columns inside an index by offering syntax accordingly. Clustering indexes can also be thought of as exceptional cases under which every column is combined in the form of a nonkey column. 

Some experts may even point out that extra leaves are only saved in B-tree leaves instead of the internal nodes, but it may be helpful in case the size of the row is bigger than that of the key.

Final Thoughts

A clustering index can easily offer the advantages of covering indexes in a convenient way, apart from improving MySQL SQL performance tuning by their implementation. 

It also provides instant performance benefits that could otherwise be tough or unattainable to gain through simple covering indexes. Some databases can regulate indexes during the process of adding information a degree of parameter quicker than different storage engines. They can also compress data, which further raises the value of clustering keys.




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