Re: Index optimization ?

From: Ragnar Hafstað <gnari(at)simnet(dot)is>
To: Bo Lorentsen <bl(at)netgroup(dot)dk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Index optimization ?
Date: 2005-01-16 16:34:42
Message-ID: 1105893282.32063.14.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 2005-01-16 at 16:25 +0100, Bo Lorentsen wrote:
[about a volatile function in a where clause not generating index scan]

> Will the only possible way to fix this be to make a volatile function
> with a return type (I know this is not possible now, but in theory) ?

this has nothing to do with the return type. a volatile function is a
function that is not garanteed to return the same value given same
input parameters, (such as currval()).

when a volatile function is used thus:
SELECT * FROM mytable WHERE col=myvolatilefunc();
the planner must call the function once per table row, and assume
possibly different return values each time, so an indexscan will
not improve timings.

on the other hand, if the function is labeled STABLE, the planner
can assume that the same value will alway be returned, so only
one call to it can be made, and an indexscan might be found the
most effective.

hope this helps

gnari

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bo Lorentsen 2005-01-16 16:45:52 Re: Index optimization ?
Previous Message Jasper Potts 2005-01-16 16:32:21 Bypass administrative permissions restriction on windows?