Search code examples
sqlperformanceindexingoracle11gsql-tuning

Oracle 11g: For the same table different query perfomance, seems like indexes destroyed for some data


I have a problem with data querying (Select) perfomance.

in the table Receivables we have account_id which is Indexed. When I run below script then for Account_ID=2003975183 it's OK, but for Account_ID=900025281 process is slowly.It's happend after the oracle server was unexpectedly stopped. Both accounts have nearly the same count of rows.

SQL Script for Accounts:

SELECT nvl(sum(invoice_amt),0) inv_amt
FROM ardb.receivables
WHERE
   acct_id = 2003975183
  AND  entry_date >= trunc(SYSDATE)
  AND  entry_date < trunc(SYSDATE) + 1;

According the trace data it seems like that Index is not working properly, is it?

Both traces for Fast ans Slow query attached:

FAST_QUERY_RESULT_TRACE

SLOWLY_QUERY_TRACE_RESULT

Kindly check and help to fix the problem. Thanks!


Solution

  • I solved the problem. After run this script and increase share pool size query working fine and in trace I can see index scan (before it was not):

    ANALYZE INDEX IDX_RECEIVABLES_ACCTID VALIDATE STRUCTURE online;