Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 164B12E0037 for ; Thu, 8 May 2008 13:42:49 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 79697-02 for ; Thu, 8 May 2008 13:42:43 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qb-out-0506.google.com (qb-out-0506.google.com [72.14.204.237]) by developer.postgresql.org (Postfix) with ESMTP id C14EB2E002D for ; Thu, 8 May 2008 13:42:44 -0300 (ADT) Received: by qb-out-0506.google.com with SMTP id e12so1472457qbe.1 for ; Thu, 08 May 2008 09:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=ydaAyV49jSiQe2f1rRLVzwJCiE1in9tO7qtbqLMxZ+U=; b=qSln215pcYw6TeMIhHFSoxD7oEsVH9ZxpPMi9BE/JP8R1XfqD6YEDS4Pd4HrJ5Jv0lhoifS/8rkN2Vm179W992oxBcHfyJn3LmLD0CugnSwQM1mmyzqI70xCRSPFyF6XCwiqa9ktFmZI3o4spIGdncW9IUZcd10DkZ2dQqipV24= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lsEKAHROJerURdbau47DZnsz+OF4qUddtKJQAHVWGVxDqv9ESWL5CUEprxVIIXJ7qUiss/nKUxlfPDhwOTbsEYzkkIh4YYfcldPWy7g86N1TvsPbJvHp5roxDycwI1v94ICMV9fU6FsZrlH5cRhbbbd36s1l6bok2xAGNdXm0jM= Received: by 10.115.77.1 with SMTP id e1mr3253467wal.208.1210264963377; Thu, 08 May 2008 09:42:43 -0700 (PDT) Received: by 10.114.137.7 with HTTP; Thu, 8 May 2008 09:42:43 -0700 (PDT) Message-ID: Date: Thu, 8 May 2008 10:42:43 -0600 From: "Scott Marlowe" To: "Julius Tuskenis" Subject: Re: [Fwd: performance: view or function?] Cc: "pgsql-admin@postgresql.org" In-Reply-To: <4822D2E6.2090004@nsoft.lt> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4822D2E6.2090004@nsoft.lt> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/65 X-Sequence-Number: 29149 On Thu, May 8, 2008 at 4:16 AM, Julius Tuskenis wrote: > Hello, > > I have one question - what is the difference between the view and a > function returning a data set? I mean the performance. Which is better to > use? If its the same, I would use functions, because I could use other > languages not just SQL to get the results I want. Note that functional indexes may be a good choice for certain actions. If you always look up tuples based on something like "where a*80+b<100 or something then a functional index on ((a*80+b)) might be more useful than a view. You can also create a custom immutable function and index on that to make it a bit cleaner.