Strange query plan

Поиск
Список
Период
Сортировка
От Dmitry Teslenko
Тема Strange query plan
Дата
Msg-id 91325fec0808140357k5bafdca5w246d38de1849fb2f@mail.gmail.com
обсуждение исходный текст
Ответы Re: Strange query plan  (Peter Eisentraut <peter_e@gmx.net>)
Re: Strange query plan  (Martin Gainty <mgainty@hotmail.com>)
Re: Strange query plan  ("Igor Neyman" <ineyman@perceptron.com>)
Список 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?

В списке pgsql-general по дате отправления:

Предыдущее
От: Clemens Schwaighofer
Дата:
Сообщение: Postgres 8.3 is not using indexes
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Postgres 8.3 is not using indexes