Subject | Plan not what I expected |
---|---|
Author | chrisacron |
Post date | 2006-07-16T05:32:55Z |
I have the following table:
CREATE TABLE IMPORTBPDATA (
SYSID CHAR(16) CHARACTER SET NONE NOT NULL COLLATE NONE,
IMPORTBATCHID CHAR(16) CHARACTER SET NONE COLLATE NONE,
STATUS INTEGER,
LINENUMBER INTEGER,
FIELD1 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD2 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD3 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD4 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD5 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
;
ALTER TABLE IMPORTBPDATA ADD CONSTRAINT PK_IMPORTBPDATA PRIMARY KEY
(SYSID);
CREATE INDEX IBD_KEYF1 ON IMPORTBPDATA(IMPORTBATCHID,FIELD1);
CREATE INDEX IBD_KEYF2 ON IMPORTBPDATA(IMPORTBATCHID,FIELD2);
CREATE INDEX IBD_KEYF3 ON IMPORTBPDATA(IMPORTBATCHID,FIELD3);
CREATE INDEX IBD_KEYF4 ON IMPORTBPDATA(IMPORTBATCHID,FIELD4);
CREATE INDEX IBD_KEYF5 ON IMPORTBPDATA(IMPORTBATCHID,FIELD5);
CREATE INDEX IBD_KEYIMPORTBATCHSTATUS ON
IMPORTBPDATA(IMPORTBATCHID,STATUS);
CREATE INDEX IBD_KEYLINENO ON IMPORTBPDATA(IMPORTBATCHID,LINENUMBER);
The following select:
SELECT * FROM ImportBPData
WHERE ImportBatchId = 'GRID0jwSl4wc2cb3'
ORDER BY Field5
And this select
SELECT * FROM ImportBPData
WHERE ImportBatchId = 'GRID0jwSl4wc2cb3'
AND Field5 STARTING WITH 'Le'
ORDER BY Field5
Both use this plan:
PLAN SORT ((IMPORTBPDATA INDEX (IBD_KEYLINENO)))
Why is it not using IBD_KEYF5 in both cases?
There are about 4000 records in the table, all with the same batch id
Any idead
CREATE TABLE IMPORTBPDATA (
SYSID CHAR(16) CHARACTER SET NONE NOT NULL COLLATE NONE,
IMPORTBATCHID CHAR(16) CHARACTER SET NONE COLLATE NONE,
STATUS INTEGER,
LINENUMBER INTEGER,
FIELD1 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD2 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD3 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD4 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
FIELD5 VARCHAR(150) CHARACTER SET NONE COLLATE NONE,
;
ALTER TABLE IMPORTBPDATA ADD CONSTRAINT PK_IMPORTBPDATA PRIMARY KEY
(SYSID);
CREATE INDEX IBD_KEYF1 ON IMPORTBPDATA(IMPORTBATCHID,FIELD1);
CREATE INDEX IBD_KEYF2 ON IMPORTBPDATA(IMPORTBATCHID,FIELD2);
CREATE INDEX IBD_KEYF3 ON IMPORTBPDATA(IMPORTBATCHID,FIELD3);
CREATE INDEX IBD_KEYF4 ON IMPORTBPDATA(IMPORTBATCHID,FIELD4);
CREATE INDEX IBD_KEYF5 ON IMPORTBPDATA(IMPORTBATCHID,FIELD5);
CREATE INDEX IBD_KEYIMPORTBATCHSTATUS ON
IMPORTBPDATA(IMPORTBATCHID,STATUS);
CREATE INDEX IBD_KEYLINENO ON IMPORTBPDATA(IMPORTBATCHID,LINENUMBER);
The following select:
SELECT * FROM ImportBPData
WHERE ImportBatchId = 'GRID0jwSl4wc2cb3'
ORDER BY Field5
And this select
SELECT * FROM ImportBPData
WHERE ImportBatchId = 'GRID0jwSl4wc2cb3'
AND Field5 STARTING WITH 'Le'
ORDER BY Field5
Both use this plan:
PLAN SORT ((IMPORTBPDATA INDEX (IBD_KEYLINENO)))
Why is it not using IBD_KEYF5 in both cases?
There are about 4000 records in the table, all with the same batch id
Any idead