Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2F7AE6509E9 for ; Thu, 10 Jul 2008 12:49:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09081-04-4 for ; Thu, 10 Jul 2008 12:49:39 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yx-out-2324.google.com (yx-out-2324.google.com [74.125.44.29]) by postgresql.org (Postfix) with ESMTP id AF407650162 for ; Thu, 10 Jul 2008 12:47:34 -0300 (ADT) Received: by yx-out-2324.google.com with SMTP id 8so955652yxb.73 for ; Thu, 10 Jul 2008 08:47:30 -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=eCXuunJ8NgPrRDXFKtQEtsOCSw2RHCaH/iYmECG4RPc=; b=rfu0KcYRBpCJ2izA7UlIGXTwhlS77zkXbfrKUQiLh70oTsw9LjpZ5IHL7GbTGH4gLB CIXpJln9zQsWeL9taARSTdR6Oz0DbRGh+OLoXAtjs1dEDFqFIn7fYmFm0GHr//OePsPV 7tSRw4klwJ0Fdg4exd8xTu77zkUU29MHxzhAE= 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=G2J2Z0JfTq8IAMuHF9eXAuHq5fSmMAZ16Z0zuJuIvWo60p9Bevv08WP1Zg0jx/btVT tCz9IkiR8LVhVg6YLcN1Nz3FuTp9qD22jbNpBjlUcwTyi2BwmEfKTD1K+xLnuDEp0bhM DiC/Qit/uJGyy2dKS2s1QvlK0auhvXKzmAzbY= Received: by 10.114.46.6 with SMTP id t6mr3191308wat.39.1215704849150; Thu, 10 Jul 2008 08:47:29 -0700 (PDT) Received: by 10.114.130.17 with HTTP; Thu, 10 Jul 2008 08:47:29 -0700 (PDT) Message-ID: Date: Thu, 10 Jul 2008 09:47:29 -0600 From: "Scott Marlowe" To: s.borse@direction.biz Subject: Re: query optimization Cc: "Julius Tuskenis" , pgsql-admin@postgresql.org In-Reply-To: <1215683144.2113.35.camel@dss-052.dsslp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1215680493.2113.26.camel@dss-052.dsslp.com> <4875D589.1030107@nsoft.lt> <1215683144.2113.35.camel@dss-052.dsslp.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/105 X-Sequence-Number: 29715 On Thu, Jul 10, 2008 at 3:45 AM, Suresh Borse wrote: > > Good Afternoon !!! > > The view executes very faster for the first time. > > When I execute the view again and again suddenly it gets slow or it gets > hang. > > I have also traced the query plan but it changes for each execution.Can we > fix the query plan. > > I have also tested the view on my test machine but the result was same. > > The view contains multi-table joins. Do you have different where clauses for each time you execute it? That can certainly affect performance each time, if you're where clause is gonna grab 99% of the view, you'll get a different plan than if you have a where clause that selects 0.01% of the table. So yeah, we need explain analyze of each type of query that's fast slow, and if there are ANY differences between them we need to know.