我在Oracle中有一个查询,单个请求需要3秒或更长时间,但在我的情况下,我多次执行它来处理多个记录,因此整体而言需要更多时间。
为了提高查询性能,我已完成以下操作。
我已经执行了SQL调优咨询并创建了建议索引,但建议索引在执行计划中不起作用,它显示了相同的先前主键索引,我将为此做些什么。
我的查询是:
Select NVL(Min(MACIDREFNO),0)
from TACID_MST
Where MacIdStatus = 2
And Status = 0
And UsedAs = 1
And IsCodeSigned = 0
And SiteRefNo = 0;
执行计划是:
Execution plan
SQL调优咨询的结果是:
GENERAL INFORMATION SECTION `Result of Tuning Advisory`
-------------------------------------------------------------------------------
Tuning Task Name : staName75534
Tuning Task Owner : TESTUSER
Tuning Task ID : 385915
Scope : COMPREHENSIVE
Time Limit(seconds) : 1800
Completion Status : COMPLETED
Started at : 01/24/2018 15:46:15
Completed at : 01/24/2018 15:46:17
Number of Index Findings : 1
-------------------------------------------------------------------------------
FINDINGS SECTION (1 finding)
-------------------------------------------------------------------------------
1- Index Finding (`see explain plans section below`)
--------------------------------------------------
The execution plan of this statement can be improved by creating one or more
indices.
Recommendation (estimated benefit: 100%)
----------------------------------------
- Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
create index TESTUSER.IDX$$_5E37B0001 on
TESTUSER.TACID_MST('STATUS','USEDAS','MACIDSTATUS','SITEREFNO','ISCODESIGNED');
Rationale
---------
Creating the recommended indices significantly improves the execution plan
of this statement. However, it might be preferable to run "Access Advisor"
using a representative SQL workload as opposed to a single statement. This
will allow to get comprehensive index recommendations which takes into
account index maintenance overhead and additional space consumption.
答案 0 :(得分:0)
最简单的方法: