Why sequential scan with index present?

From: "Michael Labhard" <ince(at)pacifier(dot)com>
To: pgsql-cygwin(at)postgresql(dot)org
Subject: Why sequential scan with index present?
Date: 2002-08-30 17:25:37
Message-ID: ako9nq$nk$1@main.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-cygwin

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";

Responses

Browse pgsql-cygwin by date

  From Date Subject
Next Message Jason Tishler 2002-08-30 19:43:06 Re: PG on Win2K
Previous Message Jason Tishler 2002-08-30 16:57:00 Re: Problem with install instructions