Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 86DFA9FB27A for ; Fri, 27 Jul 2007 10:38:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 92428-03 for ; Fri, 27 Jul 2007 10:38:42 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.237]) by postgresql.org (Postfix) with ESMTP id E90A99FB25F for ; Fri, 27 Jul 2007 10:38:47 -0300 (ADT) Received: by wr-out-0506.google.com with SMTP id 68so502071wri for ; Fri, 27 Jul 2007 06:38:46 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; 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; b=PjcB+pgJlrtgYfqCfqs96bUlpLAxM3eWVMZ6jD/mDgynZRTZJpXbmZXavgPISztPi1gvP3cLiRNeMUWXLgWUKt0tnRSxMksvcYLKANLAiKLo0p3jFpjD87zofZNkBAuURQ93Pqb5xUtsYffl6AdG21trrkjGotH68NRZShuKvok= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=na5eCjTSVTw7GVX8WzQt8BKGySL4mM2tlNgWfM4fp8OtAop4NsUo+v+m+aeh4oAxnbIBBOS1qMqe6fLA+9rPNjl6wvkeBSvWl9hAYuDFo6qE/SbuN2sIxFFs3VyTyxFk1Lv/DdUSCqjjlryok0GTk40tBpU2eWLL+vaN+jCbK0w= Received: by 10.78.185.15 with SMTP id i15mr748335huf.1185543525316; Fri, 27 Jul 2007 06:38:45 -0700 (PDT) Received: by 10.78.18.9 with HTTP; Fri, 27 Jul 2007 06:38:45 -0700 (PDT) Message-ID: Date: Fri, 27 Jul 2007 09:38:45 -0400 From: "Merlin Moncure" To: "Ranieri Mazili" Subject: Re: Tunning PostgreSQL performance for views on Windows Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org In-Reply-To: <46A8AF1B.4090607@terra.com.br> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <46A8AF1B.4090607@terra.com.br> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/1095 X-Sequence-Number: 117696 On 7/26/07, Ranieri Mazili wrote: > Hello, > > I'm developing a BI and as database it's using postgresql 8.2, how data > are very detailed, I'm creating a view to consolidate the most important > data, but the performance of view is very poor, 1 minute to perform more > or less without where clause. > I need to know how I can increase the performance, if exist some option > to do cache, because the view will change only one time per day. > My configuration is default, without modifications after install. > I'm using windows 2003 server with a dell server with 4GB of memory. PostgreSQL views are expanded on the fly by the planner...so optimizing for views is no different than standard query optimization. Views allow you to layer queries in a logical way but during execution are treated a single query (think: c macros). Set returning functions are different...they are a black box to the planner in most cases and the planner can't optimize through them. > To create the view, I created some functions, and then perform they on > one select like: > select A.field1, B.field2, ... from function_A() A, function_B() B... > Is this the best way to do it? So, the first thing I would look at would be to (if possible) rewrite function_a, b, etc as views and expose fields you filter on to the outer query in the join. While you can expose fields similarly as parameters to the function, there are various tricks that the planner can do that are not possible if some of the sql is hidden away into functions. Beyond that, you will have to give more detailed information about your problem to get more specific advise. merlin