我们的应用程序在其中一个环境中突然变慢了。我所做的唯一更改是更改了 SQL。在发布之前,SQL 是这样的
Select EmployeeId
From Employee
Where Dept='CS'
and record_state='ACTIVE'
and EmployeeTypeId ='1'
发布后的 SQL 是
Select EmployeeId
From Employee Where Dept='CS'
and record_state='ACTIVE'
and EmployeeTypeId IN ('1','2')
此表上的索引是 employee_state_id_index (Dept,record_state,EmployeeTypeId ) 该索引没有更改。这个索引对新SQL没有帮助吗?新的 SQL 会扫描整个表吗?我不知道索引如何与 in 子句一起使用。感谢您的帮助和评论
查询的解释计划是
| 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')