The execution plan is important because it allows developers and database administrators to optimize the performance of their SQL queries. By analyzing the plan, they can identify potential bottlenecks, unnecessary operations, and other areas where the query can be improved. They can then modify the query or its underlying data structures to improve performance and reduce the time it takes to retrieve the desired data.
Let's say we have a table called "Employees" with columns "FIRST_NAME", "LAST_NAME","JOB_ID", and "Salary". We want to retrieve the FIRST_NAME, LAST_NAME and salaries of all employees in the AD_VP JOB_ID who earn more than $15,000 per year.
The SQL query for this would be:
SELECT FIRST_NAME, LAST_NAME,Salary
FROM hr.Employees
WHERE JOB_ID = 'AD_VP' AND Salary > 15000;
GENERATE EXECUTION PLAN:-
EXPLAIN PLAN FOR
SELECT FIRST_NAME, LAST_NAME,Salary
FROM hr.Employees
WHERE JOB_ID = 'AD_VP' AND Salary > 15000;
Once the command has been executed, we can view the execution plan by selecting from the PLAN_TABLE: