one-field index vs. multi-field index planner estimates - Mailing list pgsql-performance

From Evgeny Gridasov
Subject one-field index vs. multi-field index planner estimates
Date
Msg-id 20060310194545.be002083.eugrid@fpm.kubsu.ru
Whole thread Raw
In response to Re: Hanging queries on dual CPU windows  (Jan de Visser <jdevisser@digitalfairway.com>)
Responses Re: one-field index vs. multi-field index planner estimates
List pgsql-performance
Hello.

Recently I've discovered an interesting thing (Postgres version 8.1.3):

example table:

CREATE TABLE test (
 id INT,
 name TEXT,
 comment TEXT,
 phone TEXT,
 visible BOOLEAN
);

then,
CREATE INDEX i1 ON test(phone);
CREATE INDEX i2 ON test(phone, visible);
CREATE INDEX i3 ON test(phone, visible) WHERE visible;

then insert lot's of data
and try to execute query like:

SELECT * FROM test WHERE phone='12345' AND visible;

uses index i1, and filters all visible fields.
When I drop index i1, postgres starts to use index i2
and the query began to work much more faster.

When I drop index i2, postgres uses index i3 which is faster than i2 ofcourse.

I've noticed that planner estimated all queries for all three cases with the same cost.
So, is it a planner bad estimate or what?

--
Evgeny Gridasov
Software Engineer
I-Free, Russia

pgsql-performance by date:

Previous
From: Jan de Visser
Date:
Subject: Re: Hanging queries on dual CPU windows
Next
From: Scott Marlowe
Date:
Subject: Re: Process Time X200