Re: Including Snapshot Info with Indexes

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
Cc: Gokulakannan Somasundaram <gokul007(at)gmail(dot)com>, Heikki Linnakangas <heikki(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Including Snapshot Info with Indexes
Date: 2007-10-09 10:30:32
Message-ID: 470B5848.8070904@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Csaba Nagy wrote:
>> Can we frame a set of guidelines, or may be some test procedure, which
>> can declare a certain function as deterministic?
>
> You mean postgres should check your function if it is really immutable ?
> I can't imagine any way to do it correctly in reasonable time :-)
> Imagine a function of 10 parameters which returns the sum of the
> parameters all the time except for parameters all 1 it will randomly
> return a value _once in a thousand executions_... please find a generic
> algorithm which spots this function as not immutable in reasonable
> execution time ;-)
> So this example is a bit extreme, but don't underestimate the user ;-)

I think you're overly pessimistic here ;-) This classification can be done quite
efficiently as long as your language is "static enough". The trick is not to
execute the function, but to scan the code to find all other functions and SQL
statements a given function may possibly call. If your function calls no SQL
statements, and only other functions already marked IMMUTABLE, then it must be
IMMUTABLE itself.

It does seem that only pl/pgsql is "static enough" for this to work, though,
making this idea rather unappealing.

>> I am just saying from the top of my mind. Even otherwise, if we can
>> even restrict this indexing to only Built-in deterministic functions.,
>> don't you think it would help the cause of a majority? I have just
>> made the proposal to create the index with snapshot a optional one.
>
> Restrictions like this are always confusing for the end user (i.e. why
> can I use built-ins here and not my own ?). I leave to the actual coders
> to say anything about code maintenance concerns...
Yes, and some built-ins have gotten that classification wrong too in the past
IIRC. Which probably is a good reason not to trust our users to get it right ;-)

greetings, Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-10-09 10:35:59 Uninformative messages from pg_ctl
Previous Message Gokulakannan Somasundaram 2007-10-09 10:29:21 IndexTuple Structure

Browse pgsql-patches by date

  From Date Subject
Next Message Csaba Nagy 2007-10-09 11:04:52 Re: Including Snapshot Info with Indexes
Previous Message Sergey V. Karpov 2007-10-09 10:02:03 Re: Preliminary patch for tsearch example dictionaries/parsers in contrib