sandeepagarwal
Technical User
I've specified optimizer hint in the following query to use the indexes.
SELECT /*+ first_rows ordered use_nl(B C) index(CUSTORDER_IDX03) index(PK_ORDERINFO)*/
UPPER(C.CITY) PUCITY,
SUM(DECODE(B.USERID, NULL, 0, 1)) WEBCOUNT,
COUNT(*) TOTALCOUNT
FROM CUSTORDER B, ORDERINFO C
WHERE B.ROUTERECID = C.ROUTERECID
AND B.CONTROLNUM = C.CONTROLNUM
AND C.PUDELFLAG = 'P'
AND B.ORDERENTDATETIME BETWEEN TO_DATE('05/30/2002 ','MM/DD/YYYY') AND TO_DATE('06/30/2002', 'MM/DD/YYYY')
GROUP BY UPPER(C.CITY)
ORDER BY TOTALCOUNT DESC;
The PK in CUSTORDER is ROUTERECID and CONTROLNUM
This is FK in ORDERINFO referencing CUSTORDER table.
The PK in ORDERINFO is ROUTERECID, CONTROLNUM and PUDELFLAG.
The index (CUSTORDER_IDX03) is on column ORDERENTDATETIME in CUSTORDER. (Excuse me for this bad index name)
I want to use this index which Oracle is not using by itself so I've specified the optimizer hint and it works!!!
The problem is if I give any date range more than 5 days it does not use this index and go for a full CUSTORDER table scan. I've tried many permutation and combination for optimizer hints but the problem area is the date column only.
Can anybody help me where what is going wrong?
I'm working on Oracle Database 8.1.7.
Sandeep.
SELECT /*+ first_rows ordered use_nl(B C) index(CUSTORDER_IDX03) index(PK_ORDERINFO)*/
UPPER(C.CITY) PUCITY,
SUM(DECODE(B.USERID, NULL, 0, 1)) WEBCOUNT,
COUNT(*) TOTALCOUNT
FROM CUSTORDER B, ORDERINFO C
WHERE B.ROUTERECID = C.ROUTERECID
AND B.CONTROLNUM = C.CONTROLNUM
AND C.PUDELFLAG = 'P'
AND B.ORDERENTDATETIME BETWEEN TO_DATE('05/30/2002 ','MM/DD/YYYY') AND TO_DATE('06/30/2002', 'MM/DD/YYYY')
GROUP BY UPPER(C.CITY)
ORDER BY TOTALCOUNT DESC;
The PK in CUSTORDER is ROUTERECID and CONTROLNUM
This is FK in ORDERINFO referencing CUSTORDER table.
The PK in ORDERINFO is ROUTERECID, CONTROLNUM and PUDELFLAG.
The index (CUSTORDER_IDX03) is on column ORDERENTDATETIME in CUSTORDER. (Excuse me for this bad index name)
I want to use this index which Oracle is not using by itself so I've specified the optimizer hint and it works!!!
The problem is if I give any date range more than 5 days it does not use this index and go for a full CUSTORDER table scan. I've tried many permutation and combination for optimizer hints but the problem area is the date column only.
Can anybody help me where what is going wrong?
I'm working on Oracle Database 8.1.7.
Sandeep.