Need your help to optimize the Query [message #657604] |
Tue, 15 November 2016 12:43 |
|
Dear Concerned:
Kindly guide me how to optimize the below query as elapsed time too long as per the tracing: (Please see below for more details)
********************************************************************************
SELECT NVL(SUM(REQ_QTY),0)FROM STOCK_TRANSFER WHERE ACCEPT_TIME IS NULL AND
GRANT_TIME IS NULL AND CANCEL_FLAG IS NULL AND PROD_ID=:B1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.37 2.63 17794 17881 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.37 2.63 17794 17881 0 1
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 65 (recursive depth: 2)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 1113 0.04 2.36
db file sequential read 63 0.02 0.04
********************************************************************************
SELECT NVL(SUM(SL_NO),0)
FROM
STOCK_TRANSFER WHERE ACCEPT_TIME IS NULL AND GRANT_TIME IS NULL AND
CANCEL_FLAG IS NULL
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.40 2.46 17414 17881 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.40 2.46 17414 17881 0 1
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 65 (recursive depth: 2)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 127 0.03 0.07
db file scattered read 1086 0.13 2.17
********************************************************************************
Expecting your kind guidance and help on this regards. Thanks in advance.
Regards,
-Mahatab.
|
|
|
|
|
|
|
|
|
|
Re: Need your help to optimize the Query [message #659318 is a reply to message #659016] |
Thu, 12 January 2017 10:53 |
skooman
Messages: 913 Registered: March 2005 Location: Netherlands
|
Senior Member |
|
|
I suppose it is to include the nulls too. By adding a constant to the index definition (0 in this case) it's a function based index that will include nulls too.
Perhaps a function based index on only those columns all null (which is a small subset of the total rows in table I guess), might be small and thus even faster.
|
|
|