Here the following is an example SQL statement with a DECODE expression syntax.
select * from employee
where decode(emp_dept, 'AAA', 'ADM','AAB','ACC',emp_dept)='ADM'
Here the following are the query plans of this SQL, it takes 6.41 seconds to finish. The query shows a Full Table Scan of EMPLOYEE table due to the DECODE expression cannot utilize the EMP_DEPT column’s index.
We can rewrite the DECODE expression...
How to Tune SQL Statement with DECODE Expression for Oracle?
select * from employee
where decode(emp_dept, 'AAA', 'ADM','AAB','ACC',emp_dept)='ADM'
Here the following are the query plans of this SQL, it takes 6.41 seconds to finish. The query shows a Full Table Scan of EMPLOYEE table due to the DECODE expression cannot utilize the EMP_DEPT column’s index.
![[IMG]](http://live.staticflickr.com/65535/50897332241_072433c7c7_b.jpg)
We can rewrite the DECODE expression...
How to Tune SQL Statement with DECODE Expression for Oracle?