0
DELETE FROM   BATCH_T   WHERE   BatchId   In (  BatchIdList  )    AND   Status   = 'CLOSED'

The above query is taking 3 mins to finish. Can anybody help me to reduce the response time.

1 Answer 1

1

If the batch list be small, then consider adding the following index to your table:

CREATE INDEX batch_idx ON BATCH_T (BatchId, Status);

If you have a very long batch list, then consider adding those values to a new table BATCH_LIST. Then, make sure that the following index exists on this new table:

CREATE INDEX other_idx ON BATCH_LIST (BatchId);

The first index should help either version.

Sign up to request clarification or add additional context in comments.

2 Comments

Indexes are created on status ,batchId columns already. basically i am calling above query from java program using jdbcTemplate.
Then check the execution plan to whether mine (your) indices are being used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.