Nested SQL Index

Our app suddenly went slow in one of the envs. The only change I made was to change the SQL. Before the release, SQL was something like this

Select EmployeeId 
From Employee 
Where Dept='CS' 
  and record_state='ACTIVE' 
  and EmployeeTypeId ='1' 

      

After SQL release

Select EmployeeId 
From Employee Where Dept='CS' 
 and record_state='ACTIVE' 
 and EmployeeTypeId IN ('1','2')

      

The index of this table is: employee_state_id_index (Dept, record_state, EmployeeTypeId) The index has not been changed. Is this index not helping new SQL? does the new SQL scan the entire table? I have no idea how indexes on a partition work. Appreciate your help and comments

Explain request plan

| Id  | Operation         | Name                     | Rows  | Bytes | Cost (%CPU)|

|   0 | DELETE STATEMENT  |                          |     1 |    57 |     4   (0)|
|   1 |  DELETE           | Employee                 |       |       |            |
|*  2 |   INDEX RANGE SCAN| employee_state_id_index  |     1 |    57 |     4   (0)|
--------------------------------------------------------------------------------

Predicate Information (identified by operation id):


PLAN_TABLE_OUTPUT


   2 - access("C"."Dept"='CS' AND
              "C"."RECORD_STATE"='ACTIVE')
       filter("C"."EmployeeTypeId"='1' OR
              "C"."EmployeeTypeId"='2')

      

+3


source to share


1 answer


The solution to the problem we faced was to re-index the table. The table had 10 million records, and we recently cleared the data in the table (when we realized we had duplicate records) and that reduced it to almost half the amount of records it previously had. Therefore, we thought that we would try to re-index, since it was necessary anyway. And it helped :)



0


source







All Articles