X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 46A9F53A72 for ; Sun, 17 Apr 2005 05:37:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 07839-02 for ; Sun, 17 Apr 2005 08:37:06 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) by svr1.postgresql.org (Postfix) with ESMTP id DFD8E53A5E for ; Sun, 17 Apr 2005 05:37:05 -0300 (ADT) Received: by rproxy.gmail.com with SMTP id j1so827206rnf for ; Sun, 17 Apr 2005 01:37:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=XYh+fpum2wJWLiH97p1Bsosfe6f0nyN4VOHm6kJcwXIClW3//3/GO+D3+CYB8w3XFVrAauQkijT4XvzlhJgJ6o5fdfezqvFQjF4Ylx11AFO/eaNqiSFFEGtcy4y1ty+Gb9h9Qbl9FY5gaX1thcm3N/0qVo6AyIPNvdU7u01aoKg= Received: by 10.38.82.20 with SMTP id f20mr4790022rnb; Sun, 17 Apr 2005 01:37:07 -0700 (PDT) Received: by 10.38.97.29 with HTTP; Sun, 17 Apr 2005 01:37:07 -0700 (PDT) Message-ID: Date: Sun, 17 Apr 2005 03:37:07 -0500 From: Jaime Casanova Reply-To: Jaime Casanova To: weigelt@metux.de, pgsql-performance@postgresql.org Subject: Re: immutable functions vs. join for lookups ? In-Reply-To: <20050417060603.GA23283@nibiru.borg.metux.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050415205511.GB20345@nibiru.borg.metux.de> <6776.1113599567@sss.pgh.pa.us> <20050417060603.GA23283@nibiru.borg.metux.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.314 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200504/377 X-Sequence-Number: 11774 On 4/17/05, Enrico Weigelt wrote: > * Tom Lane wrote: > > Enrico Weigelt writes: > > > c) CREATE FUNCTION id2username(oid) RETURNS text > > > LANGUAGE 'SQL' IMMUTABLE AS ' > > > SELECT username AS RESULT FROM users WHERE uid =3D $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. >=20 > In my case it is immutable. The username never changes. >=20 Even if your data never changes it *can* change so the function should be at most stable not immutable. regards, Jaime Casanova