A table is created with an index on a column, but the select does a
sequential scan anyway. Why?
Thanks.
-- Michael
CREATE TABLE "tblRTContractDays"(
id SERIAL PRIMARY KEY
, symbol_id INTEGER NOT NULL
, on_date DATE NOT NULL
)
;
CREATE INDEX "tblRTContractDays_on_date_indx"
ON "tblRTContractDays"(on_date);
INSERT INTO "tblRTContractDays"(symbol_id, on_date) VALUES (1,
CURRENT_DATE);
INSERT INTO "tblRTContractDays"(symbol_id, on_date) VALUES (1,
CURRENT_DATE - CAST('1 day' AS INTERVAL));
INSERT INTO "tblRTContractDays"(symbol_id, on_date) VALUES (1,
CURRENT_DATE - CAST('2 day' AS INTERVAL));
EXPLAIN SELECT symbol_id, on_date FROM "tblRTContractDays" WHERE on_date
< CURRENT_DATE;
DROP TABLE "tblRTContractDays";
DROP SEQUENCE "tblRTContractDays_id_seq";