pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Merlin Moncure <mmoncure@gmail.com>
To: Stuart Bishop <stuart.bishop@canonical.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow functional indexes?
Date: Sat, 21 Oct 2006 08:09:31 +0530
Message-ID: <b42b73150610201939v250e4314yfc86f06568ac97d7@mail.gmail.com> (raw)
In-Reply-To: <45387666.204@canonical.com>
References: <45387666.204@canonical.com>

On 10/20/06, Stuart Bishop <stuart.bishop@canonical.com> wrote:
> I would like to understand what causes some of my indexes to be slower to
> use than others with PostgreSQL 8.1. On a particular table, I have an int4
> primary key, an indexed unique text 'name' column and a functional index of
> type text. The function (person_sort_key()) is declared IMMUTABLE and
> RETURNS NULL ON NULL INPUT.

database will not allow you to create index if the function is not immutable.

> A simple query ordering by each of these columns generates nearly identical
> query plans, however runtime differences are significantly slower using the
> functional index. If I add a new column to the table containing the result
> of the function, index it and query ordering by this new column then the
> runtime is nearly an order of magnitude faster than using the functional
> index (and again, query plans are nearly identical).

> demo=# explain analyze select * from person order by id offset 527000 limit 50;
>                                                                  QUERY PLAN

it looks you just turned up a bad interaction between a functional
index and 'offset' probably your function is getting executed extra
times or there is a sort going on.  however, I'd suggest not using
'offset', because its bad design.

merlin



view thread (7+ messages)  latest in thread

Message-ID: <b42b73150610201939v250e4314yfc86f06568ac97d7@mail.gmail.com>
Permalink:  ../b42b73150610201939v250e4314yfc86f06568ac97d7@mail.gmail.com/
Also on:    postgresql.org/message-id/b42b73150610201939v250e4314yfc86f06568ac97d7@mail.gmail.com

 · 

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: mmoncure@gmail.com, stuart.bishop@canonical.com
  Subject: Re: Slow functional indexes?
  In-Reply-To: <b42b73150610201939v250e4314yfc86f06568ac97d7@mail.gmail.com>
  References: <45387666.204@canonical.com> <b42b73150610201939v250e4314yfc86f06568ac97d7@mail.gmail.com>

* 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