Subject | Problem with plan selection - doesn't seem right |
---|---|
Author | Michael L. Horne |
Post date | 2002-12-12T20:13:32Z |
Hello,
Got a table setup like
-------------------------------------------------------------------
CREATE TABLE ORDERSD (
OD_ID T_ID,
OD_OM_ID T_ID,
OD_SEQNUM T_INTEGER,
OD_PART T_PART);
ALTER TABLE ORDERSD ADD CONSTRAINT ORDERSDBYID PRIMARY KEY (OD_ID);
CREATE INDEX ORDERSDBYINVOICEM ON ORDERSD (OD_OM_ID, OD_ID);
CREATE DESCENDING INDEX ORDERSDBYSEQNUM ON ORDERSD (OD_OM_ID, OD_SEQNUM);
-------------------------------------------------------------------
When I run the following SQL it uses the plan below:
select max(od_seqnum)
from ordersd
where od_om_id = 25433
-------------------------------------------------------------------
The Plan:
PLAN (ORDERSD INDEX (ORDERSDBYINVOICEM))
-------------------------------------------------------------------
Shouldn't it be using the "OrdersdBySeqnum" index, that one is decending and
on the fields being accessed? Why doesn't it.
Thanks
Michael L. Horne
Got a table setup like
-------------------------------------------------------------------
CREATE TABLE ORDERSD (
OD_ID T_ID,
OD_OM_ID T_ID,
OD_SEQNUM T_INTEGER,
OD_PART T_PART);
ALTER TABLE ORDERSD ADD CONSTRAINT ORDERSDBYID PRIMARY KEY (OD_ID);
CREATE INDEX ORDERSDBYINVOICEM ON ORDERSD (OD_OM_ID, OD_ID);
CREATE DESCENDING INDEX ORDERSDBYSEQNUM ON ORDERSD (OD_OM_ID, OD_SEQNUM);
-------------------------------------------------------------------
When I run the following SQL it uses the plan below:
select max(od_seqnum)
from ordersd
where od_om_id = 25433
-------------------------------------------------------------------
The Plan:
PLAN (ORDERSD INDEX (ORDERSDBYINVOICEM))
-------------------------------------------------------------------
Shouldn't it be using the "OrdersdBySeqnum" index, that one is decending and
on the fields being accessed? Why doesn't it.
Thanks
Michael L. Horne