Tuesday, March 9, 2010

A case where a hint has to be applied

I usually do not use hint but today I have to use one

Below is the script

SELECT /*+ index(cdr_customer_mv CDR_CUST_MV_CSTCD_ACCT_YR) */ 
    *

  FROM ds_prod.cdr_customer_mv
WHERE  acct_period >=
TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE - 9, -3), 'yyyymm'))

 

The weird thing is that if I do not use > and only use =, then there is no need to use the hint as the explain plan indicates the usage of index. However, when I apply the >, it starts to scan the full table.

  Anyway, it’s good to know this…

No comments:

Post a Comment