pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Evgeny Gridasov <eugrid@fpm.kubsu.ru>
To: pgsql-performance@postgresql.org
Subject: one-field index vs. multi-field index planner estimates
Date: Fri, 10 Mar 2006 19:45:45 +0300
Message-ID: <20060310194545.be002083.eugrid@fpm.kubsu.ru> (raw)
In-Reply-To: <200603101113.35868.jdevisser@digitalfairway.com>
References: <6BCB9D8A16AC4241919521715F4D8BCEA35109@algol.sollentuna.se>
	<200603101113.35868.jdevisser@digitalfairway.com>

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



view thread (4+ messages)  latest in thread

Message-ID: <20060310194545.be002083.eugrid@fpm.kubsu.ru>
Permalink:  ../20060310194545.be002083.eugrid@fpm.kubsu.ru/
Also on:    postgresql.org/message-id/20060310194545.be002083.eugrid@fpm.kubsu.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: eugrid@fpm.kubsu.ru
  Subject: Re: one-field index vs. multi-field index planner estimates
  In-Reply-To: <20060310194545.be002083.eugrid@fpm.kubsu.ru>
  References: <6BCB9D8A16AC4241919521715F4D8BCEA35109@algol.sollentuna.se> <200603101113.35868.jdevisser@digitalfairway.com> <20060310194545.be002083.eugrid@fpm.kubsu.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox