From s.borse@direction.biz Thu Jul 10 09:12:34 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 7D84F65050C for ; Thu, 10 Jul 2008 06:12:34 -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 07725-05 for ; Thu, 10 Jul 2008 06:12:25 -0300 (ADT) X-Greylist: delayed 00:06:38.598846 by SQLgrey-1.7.6 Received: from ns1.aaaonlinux.net (NS1.AAAONLINUX.net [70.84.189.18]) by postgresql.org (Postfix) with ESMTP id 4D7A265032E for ; Thu, 10 Jul 2008 06:12:28 -0300 (ADT) Received: (qmail 25752 invoked by uid 508); 10 Jul 2008 09:11:12 -0000 Received: from unknown (HELO direction.biz) (59.163.21.147) by ns1.aaaonlinux.net with SMTP; 10 Jul 2008 09:11:12 -0000 Received: from [172.16.2.20] ([172.16.2.20]) (authenticated user s.borse@direction.biz) by direction.biz (direction.biz) (MDaemon PRO v9.0.0) with ESMTP id md50001972541.msg for ; Thu, 10 Jul 2008 14:33:56 +0530 Subject: query optimization From: Suresh Borse Reply-To: s.borse@direction.biz To: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary="=-muCmwfxQFEheGbnwD5h1" Organization: DSS Date: Thu, 10 Jul 2008 14:31:33 +0530 Message-Id: <1215680493.2113.26.camel@dss-052.dsslp.com> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-9.fc7) X-Authenticated-Sender: s.borse@direction.biz X-Spam-Processed: direction.biz, Thu, 10 Jul 2008 14:33:56 +0530 (not processed: spam filter heuristic analysis disabled) X-MDRemoteIP: 172.16.2.20 X-Return-Path: s.borse@direction.biz X-MDaemon-Deliver-To: pgsql-admin@postgresql.org X-MDAV-Processed: direction.biz, Thu, 10 Jul 2008 14:33:57 +0530 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.269 tagged_above=0 required=5 tests=AWL=0.268, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200807/98 X-Sequence-Number: 29708 --=-muCmwfxQFEheGbnwD5h1 Content-Type: text/plain Content-Transfer-Encoding: 7bit Dear All, I am facing very strange problem in postgres while executing the view. When I execute the view some times it takes few milliseconds, sometimes it take several seconds and some times doesn't execute. I tried to troubleshoot using the explain plan method. But explain plan also changes for each execution. Can anybody help me for troubleshooting and for resolving the performance issue. Thanks & Regards, Suresh Borse --=-muCmwfxQFEheGbnwD5h1 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Dear All,

I am facing very strange problem in postgres while executing the view.

When I execute the view some times it takes few milliseconds, sometimes it take several seconds and some times doesn't execute.

I tried to troubleshoot using the explain plan method. But explain plan also changes for each execution.

Can anybody help me for troubleshooting  and for resolving the performance issue.


Thanks & Regards,
Suresh Borse


--=-muCmwfxQFEheGbnwD5h1-- From julius@nsoft.lt Thu Jul 10 09:25:40 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C8153650548 for ; Thu, 10 Jul 2008 06:25:40 -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 20768-01 for ; Thu, 10 Jul 2008 06:25:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vilnius.balt.net (vilnius.balt.net [195.14.170.14]) by postgresql.org (Postfix) with ESMTP id BCF5C65052F for ; Thu, 10 Jul 2008 06:25:33 -0300 (ADT) Received: from nSoft.lt (unknown [217.117.29.29]) by vilnius.balt.net (Postfix) with ESMTP id A8DA33A1311; Thu, 10 Jul 2008 12:25:29 +0300 (EEST) Received: from [192.168.16.3] (unknown [192.168.16.3]) by nSoft.lt (Postfix) with ESMTP id 12E15BEE07; Thu, 10 Jul 2008 12:53:20 +0000 (GMT) Message-ID: <4875D589.1030107@nsoft.lt> Date: Thu, 10 Jul 2008 12:25:29 +0300 From: Julius Tuskenis User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: s.borse@direction.biz CC: pgsql-admin@postgresql.org Subject: Re: query optimization References: <1215680493.2113.26.camel@dss-052.dsslp.com> In-Reply-To: <1215680493.2113.26.camel@dss-052.dsslp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.166 tagged_above=0 required=5 tests=AWL=0.166 X-Spam-Level: X-Archive-Number: 200807/99 X-Sequence-Number: 29709 Hello, Suresh Maybe its taking long for the first time, and then its faster? Did you noticed any circumstances under witch your query takes longer to execute? Suresh Borse rašė: > Dear All, > > I am facing very strange problem in postgres while executing the view. > > When I execute the view some times it takes few milliseconds, > sometimes it take several seconds and some times doesn't execute. > > I tried to troubleshoot using the explain plan method. But explain > plan also changes for each execution. > > Can anybody help me for troubleshooting and for resolving the > performance issue. > > > Thanks & Regards, > Suresh Borse > > -- Julius Tuskenis Programavimo skyriaus vadovas UAB nSoft mob. +37068233050 From s.borse@direction.biz Thu Jul 10 09:50:17 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 2C25C65052F for ; Thu, 10 Jul 2008 06:50:17 -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 41014-10 for ; Thu, 10 Jul 2008 06:49:58 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ns1.aaaonlinux.net (NS1.AAAONLINUX.net [70.84.189.18]) by postgresql.org (Postfix) with ESMTP id 98024650332 for ; Thu, 10 Jul 2008 06:50:01 -0300 (ADT) Received: (qmail 23290 invoked by uid 508); 10 Jul 2008 09:55:26 -0000 Received: from unknown (HELO direction.biz) (59.163.21.147) by ns1.aaaonlinux.net with SMTP; 10 Jul 2008 09:55:25 -0000 Received: from [172.16.2.20] ([172.16.2.20]) (authenticated user s.borse@direction.biz) by direction.biz (direction.biz) (MDaemon PRO v9.0.0) with ESMTP id md50001972626.msg for ; Thu, 10 Jul 2008 15:18:05 +0530 Subject: Re: query optimization From: Suresh Borse Reply-To: s.borse@direction.biz To: Julius Tuskenis Cc: pgsql-admin@postgresql.org In-Reply-To: <4875D589.1030107@nsoft.lt> References: <1215680493.2113.26.camel@dss-052.dsslp.com> <4875D589.1030107@nsoft.lt> Content-Type: multipart/alternative; boundary="=-rkT+VYTd7fJpDg7RTVFq" Organization: DSS Date: Thu, 10 Jul 2008 15:15:44 +0530 Message-Id: <1215683144.2113.35.camel@dss-052.dsslp.com> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-9.fc7) X-Authenticated-Sender: s.borse@direction.biz X-Spam-Processed: direction.biz, Thu, 10 Jul 2008 15:18:05 +0530 (not processed: spam filter heuristic analysis disabled) X-MDRemoteIP: 172.16.2.20 X-Return-Path: s.borse@direction.biz X-MDaemon-Deliver-To: pgsql-admin@postgresql.org X-MDAV-Processed: direction.biz, Thu, 10 Jul 2008 15:18:07 +0530 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.202 tagged_above=0 required=5 tests=AWL=0.201, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200807/101 X-Sequence-Number: 29711 --=-rkT+VYTd7fJpDg7RTVFq Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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. Warm Regards, Suresh Borse On Thu, 2008-07-10 at 12:25 +0300, Julius Tuskenis wrote: > Hello, Suresh > > Maybe its taking long for the first time, and then its faster? Did you > noticed any circumstances under witch your query takes longer to execute? > > > Suresh Borse rašė: > > Dear All, > > > > I am facing very strange problem in postgres while executing the view. > > > > When I execute the view some times it takes few milliseconds, > > sometimes it take several seconds and some times doesn't execute. > > > > I tried to troubleshoot using the explain plan method. But explain > > plan also changes for each execution. > > > > Can anybody help me for troubleshooting and for resolving the > > performance issue. > > > > > > Thanks & Regards, > > Suresh Borse > > > > > > --=-rkT+VYTd7fJpDg7RTVFq Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit
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.

Warm Regards,
Suresh Borse



On Thu, 2008-07-10 at 12:25 +0300, Julius Tuskenis wrote:
Hello, Suresh

Maybe its taking long for the first time, and then its faster? Did you 
noticed any circumstances under witch your query takes longer to execute?


Suresh Borse rašė:
> Dear All,
>
> I am facing very strange problem in postgres while executing the view.
>
> When I execute the view some times it takes few milliseconds, 
> sometimes it take several seconds and some times doesn't execute.
>
> I tried to troubleshoot using the explain plan method. But explain 
> plan also changes for each execution.
>
> Can anybody help me for troubleshooting  and for resolving the 
> performance issue.
>
>
> Thanks & Regards,
> Suresh Borse
>
>


--=-rkT+VYTd7fJpDg7RTVFq-- From julius@nsoft.lt Thu Jul 10 10:39:13 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A9280650162 for ; Thu, 10 Jul 2008 07:39:13 -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 93950-08 for ; Thu, 10 Jul 2008 07:39:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from vilnius.balt.net (vilnius.balt.net [195.14.170.14]) by postgresql.org (Postfix) with ESMTP id 818FE65015E for ; Thu, 10 Jul 2008 07:39:08 -0300 (ADT) Received: from nSoft.lt (unknown [217.117.29.29]) by vilnius.balt.net (Postfix) with ESMTP id 0D6093A12BB; Thu, 10 Jul 2008 13:39:05 +0300 (EEST) Received: from [192.168.16.3] (unknown [192.168.16.3]) by nSoft.lt (Postfix) with ESMTP id 67078BEE07; Thu, 10 Jul 2008 14:06:55 +0000 (GMT) Message-ID: <4875E6C9.3090706@nsoft.lt> Date: Thu, 10 Jul 2008 13:39:05 +0300 From: Julius Tuskenis User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: s.borse@direction.biz CC: pgsql-admin@postgresql.org Subject: Re: query optimization References: <1215680493.2113.26.camel@dss-052.dsslp.com> <4875D589.1030107@nsoft.lt> <1215683144.2113.35.camel@dss-052.dsslp.com> In-Reply-To: <1215683144.2113.35.camel@dss-052.dsslp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.161 tagged_above=0 required=5 tests=AWL=0.161 X-Spam-Level: X-Archive-Number: 200807/102 X-Sequence-Number: 29712 Please send the "explain analyze YOUR_QUERY" output after first run and later. Also please mention platform and pg version you are using. Suresh Borse rašė: > > 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. > > Warm Regards, > Suresh Borse > > > > On Thu, 2008-07-10 at 12:25 +0300, Julius Tuskenis wrote: >> Hello, Suresh >> >> Maybe its taking long for the first time, and then its faster? Did you >> noticed any circumstances under witch your query takes longer to execute? >> >> >> Suresh Borse rašė: >> > Dear All, >> > >> > I am facing very strange problem in postgres while executing the view. >> > >> > When I execute the view some times it takes few milliseconds, >> > sometimes it take several seconds and some times doesn't execute. >> > >> > I tried to troubleshoot using the explain plan method. But explain >> > plan also changes for each execution. >> > >> > Can anybody help me for troubleshooting and for resolving the >> > performance issue. >> > >> > >> > Thanks & Regards, >> > Suresh Borse >> > >> > >> >> >> -- Julius Tuskenis Programavimo skyriaus vadovas UAB nSoft mob. +37068233050 From scott.marlowe@gmail.com Thu Jul 10 15:49:45 2008 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. From tgl@sss.pgh.pa.us Thu Jul 10 16:21:56 2008 Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 859AB65003C for ; Thu, 10 Jul 2008 13:21:56 -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 41263-07 for ; Thu, 10 Jul 2008 13:21:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 25F2F64FD42 for ; Thu, 10 Jul 2008 13:21:52 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m6AGLixc009896; Thu, 10 Jul 2008 12:21:44 -0400 (EDT) To: s.borse@direction.biz, "Julius Tuskenis" , pgsql-admin@postgresql.org Subject: Re: query optimization In-reply-to: References: <1215680493.2113.26.camel@dss-052.dsslp.com> <4875D589.1030107@nsoft.lt> <1215683144.2113.35.camel@dss-052.dsslp.com> Comments: In-reply-to "Scott Marlowe" message dated "Thu, 10 Jul 2008 09:47:29 -0600" Date: Thu, 10 Jul 2008 12:21:44 -0400 Message-ID: <9895.1215706904@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/106 X-Sequence-Number: 29716 On Thu, Jul 10, 2008 at 3:45 AM, Suresh Borse wrote: >> 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. >> The view contains multi-table joins. Uh, how many joins? If you're exceeding geqo_threshold then you would get plans with a random component to them. You might want to increase the threshold, although planning time would probably go up. Also, what PG version is this? regards, tom lane