Re: immutable functions vs. join for lookups ?

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: weigelt(at)metux(dot)de, pgsql-performance(at)postgresql(dot)org
Subject: Re: immutable functions vs. join for lookups ?
Date: 2005-04-17 08:37:07
Message-ID: c2d9e70e05041701372aee3a2c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 4/17/05, Enrico Weigelt <weigelt(at)metux(dot)de> wrote:
> * Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Enrico Weigelt <weigelt(at)metux(dot)de> writes:
> > > c) CREATE FUNCTION id2username(oid) RETURNS text
> > > LANGUAGE 'SQL' IMMUTABLE AS '
> > > SELECT username AS RESULT FROM users WHERE uid = $1';
> >
> > This is simply dangerous. The function is *NOT* immutable (it is
> > stable though). When ... not if ... your application breaks because
> > you got the wrong answers, you'll get no sympathy from anyone.
>
> In my case it is immutable. The username never changes.
>
Even if your data never changes it *can* change so the function should
be at most stable not immutable.

regards,
Jaime Casanova

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Alex 2005-04-17 12:56:47 Re: plperl vs plpgsql
Previous Message Enrico Weigelt 2005-04-17 06:06:04 Re: immutable functions vs. join for lookups ?