In my previous article i have given the details about different oracle indexes and how to use those oracle indexes in detail.In this article i would like to give you example and explanation about Oracle explain plan in detail. The Oracle explain plan is most important concept if you want to start work with SQL performance tuning. What is explain plan? – Explain plan is nothing the the execution plan for the query set by the oracle optimizer by considering multiple factors.
What we will see in this article?
The Oracle explain plan is nothing but the execution plan in readable format with using which user can check ,analyse and tune the SQL queries. The explain plans are first entry point if you want to tune the query. These are the execution plan or execution path for SQL query execution set by oracle optimizer.
There are set of things you require to know before reading explain plan. I will explain those in detail in separate article.
1.Join Methods in Oracle Engine
2.Access Methods of Oracle E.g. Full table scan
3.Data operations in the query E.g. Filter,Sort,aggregation
There are always separate methods to join tables internally in oracle engine. There are three types of join methods we are used internally in oracle sql performance tuning.
Access Methods used by Oracle Optimizer :
I will not go deep in to the access methods and will only name the access methods to remember :
The next question in mind that how to read the oracle explain plan in detail and what is method to display and analyse it. To generate explain plan there are multiple ways
Oracle SQL developer : You can use the direct F9 button to display the explain plan in detail.
With using multiple queries :
You can use different queries to execute the explain plan in oracle sql.
Query 1 :
Explain plan for ….Query
Query 2 :
select * from table(dbms_xplan.disaplay);
Example :
I am using the example for Employees table in HR schema to explain that in detail .
The Columns in Explain plan :
The explain plan in nothing but the set of steps to query execution. The first column is id column which is the statement no. Then the operation is nothing but any operation performed on the query like select,insert or update.
The rows column gives you number of rows for the specified operation and bytes is number of bytes used for the specified operation. The time is nothing but the time for execution for the specified SQL operation.
Explain plan in table format :
You can also check the explain plan in table format using plan_table. You require to check the specified plan id checking the timestamp column.
select * from plan_table where plan_id=31;
I would like to give more examples to show the different explain plans and operations. To make it more complex i am joining two tables and will show you the explain plan.
Explain plan for
Select * from Hr.employees a, hr.departments b
where a.employee_id = b.manager_id;
If you can execute and check the explain plan there are so many operations. In above query you can check that there is nested join between department and employees table and the employee table is unique index scan. You can check the different operations as well.
This is all about the reading explain plan in oracle with multiple examples. I hope this article is useful to you. If you like this article or if you have any issues with the same kindly comment in comments section.
Introduction Cryptocurrencies took the world by storm, setting up a new financial system and breaking…
In my previous article I have given Top 20 technical support interview questions with its…
In my previous articles I have given 15 most asked desktop support interview questions with…
A business analyst is someone who is versed in processes of data analysis used for…
In my previous article I have already given top questions and answers for Desktop support…
In my previous article I have given unix production support interview questions and answers. In…