Strange query plan

From: "Dmitry Teslenko" <dteslenko(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Strange query plan
Date: 2008-08-14 10:57:09
Message-ID: 91325fec0808140357k5bafdca5w246d38de1849fb2f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello!

I have following table:

CREATE TABLE table1 (
field1 INTEGER NOT NULL,
field2 INTEGER NOT NULL,
field3 CHARACTER(30),
... some more numeric fields)

I have also those indexes:

CREATE UNIQUE INDEX idx1 ON table1 USING btree (field3, field2, field1)
CREATE INDEX idx2 ON table1 USING btree (field1, field3)

Then I query this table with something like this:

SELECT SUM(...) FROM table1 WHERE field3 = 'ABC' AND field1 <> 1
GROUP BY field2

And planner picks up a sequential scan of a table. Why does he?

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2008-08-14 11:27:21 Re: Postgres 8.3 is not using indexes
Previous Message Daneel 2008-08-14 10:22:32 Re: Newbie [CentOS 5.2] service postgresql initdb