Re: Index on immutable function call

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: "Tore Halvorsen" <tore(dot)halvorsen(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Index on immutable function call
Date: 2010-01-19 10:57:31
Message-ID: 372CE753-50D7-4596-BA45-F3FF77798796@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I have tried with a combined index:
>
> create index long_transformation_index on indexed_table (data1,
> this_is_a_long_transformation(data2));
>
> Unfortunately, it does not work:
>
> -------------------------------
> Seq Scan on indexed_table (cost=0.00..26791.00 rows=33333 width=12)
> (actual time=0.327..5805.199 rows=49959 loops=1)
> Filter: (data1 > this_is_a_long_transformation(data2))
> Total runtime: 6340.772 ms
> -------------------------------

Strange. I noticed that the number of records you get from each method differs somewhat, are you recreating the database each time?

With the combined index, or just an index on each column; if you disable seqscans (set enable_seqscan to false), at what cost does the planner estimate the bitmap index scan that I expect you'll get in that case? Can you show us the output of explain for that case?

I don't get why it'd be estimated so much more expensive than the partial index Tore came up with that it would prefer a seqscan. Tore's index would create a better balanced tree as serial is guaranteed to be unique, while data1 and data2 aren't (collisions).

It's all probably an artefact of the randomness of your data - many of the statistics the planner tracks are quite useless here. Real data tends to be a lot less random so estimates are usually much better there.

Alban Hertroys

--
Screwing up is the best way to attach something to the ceiling.

!DSPAM:737,4b55902010601090241314!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2010-01-19 11:08:42 Re: postgres external table
Previous Message Timo Klecker 2010-01-19 10:48:39 Re: Index on immutable function call