Re: Strange query plan

From: "Igor Neyman" <ineyman(at)perceptron(dot)com>
To: "Dmitry Teslenko" <dteslenko(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Strange query plan
Date: 2008-08-14 13:55:33
Message-ID: F4C27E77F7A33E4CA98C19A9DC6722A2035149BD@EXCHANGE.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-----Original Message-----
From: Dmitry Teslenko [mailto:dteslenko(at)gmail(dot)com]
Sent: Thursday, August 14, 2008 6:57 AM
To: pgsql-general(at)postgresql(dot)org
Subject: Strange query plan

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?

[I.N.]
How big is your table?
If it's not too big, the cost of table scan might be lower than using
index.

Igor

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Teslenko 2008-08-14 14:28:49 Re: Strange query plan
Previous Message Gauthier, Dave 2008-08-14 13:43:44 Re: Strange query plan