Showing posts with label database query optimization. Show all posts
Showing posts with label database query optimization. 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

 

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. 


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.



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. 

Tuesday, 15 June 2021

SQL Optimizer for SQL Server: Deleting Old Backup Files

SQL Server

Creating and maintaining backups are an essential part of a DBA’s responsibilities. There are several tasks associated with backups, such as automation and execution of backup command scripts.

Sometimes, it is important to know how to automate the deletion of outdated backup files as well, even if you already have a SQL optimizer for SQL Server. In this post, we will discuss a simple approach to help you remove older backup data and save space.


How to Delete Backup Files without SQL Optimizer for SQL Server

Here, we will make use of Windows Scripting to traverse every subfolder in order to locate files preceding a specific date. We will then delete the older files, once they have all been located.

First, we need to consider two parameters that must be modified for this purpose:

 

       iDaysOld - this helps you set the exact timeframe to determine how old the file has to be for the command to select and delete it

       strPath - this is the path to the folder where the backup files are created and stored.

 

SQL optimizer for SQL Server

Steps to establish the script before you get to SQL Server performance tuning:


  1. You need to create a text file where you can copy and paste the following code -

iDaysOld = 15

strPath = “C:\Backup”

Set objFSO = CreateObject("Scripting.FileSystemObject") 

Set objFolder = objFSO.GetFolder(strPath) 

Set colSubfolders = objFolder.Subfolders 

Set colFiles = objFolder.Files 

 

For Each objFile in colFiles 

   If obj!File.Date!LastModified < (Date() - iDays!Old) Then 

       Msg!Box "Dir: " & obj!Folder.Name & vbCrLf & "File: " & objFile.Name!

       'obj!File.Delete! 

   End If 

Next 

 

For Each objSubfolder in colSubfolders 

   Set colFiles = objSubfolder.Files 

   For Each objFile in colFiles 

       If obj!File.Date!LastModified < (Date!() - iDaysOld) Then 

           Msg!Box "Dir: " & obj!Subfolder.Name & vb!CrLf & "File: " & obj!File.Name

           'objFile.Delete 

       End If 

   Next 

Next

Use the path of your choice as strPath - for instance, “strPath = “C:\Backup””. Remove the exclamation marks before or after you paste this code.

 

SQL Server performance tuning

  1. Save it using a suitable name like this - C:\RemoveBackupFilesOld.vbs

 

  1. Create one more text file in which you will copy-paste the code mentioned below, and save it as a BAT file in the same location. For instance, you can name it as - C:\RemoveBackupFilesOld.bat.

The code: C:\RemoveBackupFilesOld.vbs

 

Please note that this script serves as a safeguard, so it will only show a message box that displays the name of the file and folder. If you’re using an optimization of SQL queries SQL optimizer for SQL Server and you want to actually delete the files, simply remove the single quote character that’s present right next to the two delete lines (the ones with ‘objFile.Delete).

 

  1. Running the BAT file will delete all the files matching the specified criteria from their subfolders.

 

How the Script Works

 

The script will pick out and eliminate any files found in the subfolders beyond the initial point. The type of the files doesn’t matter as it will only consider the time of creation and whether it fulfils the specified criteria.

It will also remove files from subfolders in the next level as well as the root folder but it won’t fetch files past the first subfolder level. In other words, if you put the strPath as “C:\Backup” for instance, the script will remove backup files older than the iDaysOld that are present in the “C:\Backup” folder and those present in the first level subfolders inside this folder.

You may set this script up to run at a scheduled time according to your need - just call the BAT file. This is because, as you may have learned during SQL Server performance tuning, the Agent is not accustomed to running .vbs (VBScript) files directly, which is why we’re calling a BAT to set it up as a scheduled task instead.






Thursday, 27 May 2021

SQL Performance Monitoring & 6 Other Top Basic DBA Skills


As time passes, human resources are rapidly getting replaced by computing resources, affecting the task range of an Oracle DBA. You may have observed the consolidation of Oracle instances onto a bigger server with a greater number of CPUs. Due to this, fewer DBA professionals are needed by organizations. 

At the same time, a DBAs list of tasks keeps increasing since the same set of activities needs to be completed by fewer staff. From schema design handling to SQL performance monitoring, there are many essential database management duties assigned to surviving DBAs. On the bright side, Oracle DBAs no longer have to perform tedious tasks such as implementing patches on several servers and perpetually re-assigning server resources. re-allocating server resources, and t
uning many servers.

6 Most Important Skills for a Database Administrator

Since a professional Oracle DBA is generally brought into crucial IT department undertakings, authorities may often give preference to professionals with a wider range of both Oracle-based and non-Oracle-based job skills.


While the applicants usually have all the Oracle-based skills gained in academic Information Technology and Computer Science courses, they may or may not have some of the Non-Oracle job skills, including the following:

  • Database Design – Numerous projects need an understanding of concepts such as data modeling methods, database normalization, and STAR schema.
  • System Analysis – Oracle specialists often end up playing an important part in designing and analyzing new DBMSs. Therefore, they should be aware of concepts such as DFDs (data flow diagrams), CASE tools, methodologies in entity-relation shaping, and data dictionary techniques.
  • Change Control Management – Aside from knowing how to
    performance tune SQL query, the candidate should know how to implement change control as they are likely to be handed over that responsibility. They also must be able to make sure those changes are sufficiently carried out to the production database aside from knowing about the third-party change control resources such as the UNIX Source Code Control System (SCCS).
  • Physical Disk Storing – They need to have knowledge of RAID, cache controllers, disk hardware architecture, and disk load balancing.
  • Backup and Recovery – Since a majority of projects use third-party backup and recovery technologies, the DBA requires proper experience implementing these methods.

  • Data Security skills – Excellent knowledge of MySQL SQL performance tuning and how to implement database security measures in RDBMS, especially role-based security is quite useful.


Conclusion

Many Oracle users and specialists wrongly believe that a database administrator in Oracle only needs to have technical skills such as how to performance tune SQL query. However, the Oracle DBA needs to have a much broader range of skills as they not only have the responsibility of the design but also various other elements of the database such as implementation, storage, and data recovery. 

Therefore, they require good technical and communication skills to handle all the different aspects of database management in the best way possible and keep operations streamlined among all these areas. 








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