Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E7E461337B8A for ; Fri, 14 Jan 2011 09:53:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 20703-01 for ; Fri, 14 Jan 2011 13:53:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mail.postgresql.org (Postfix) with ESMTP id 5322E133616B for ; Fri, 14 Jan 2011 09:53:39 -0400 (AST) Received: from smadev.internal.net (localhost.internal.net [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id p0EDrcXj009396 for ; Fri, 14 Jan 2011 15:53:38 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id p0EDrcoW009395 for pgsql-admin@postgresql.org; Fri, 14 Jan 2011 15:53:38 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-admin@postgresql.org Subject: Re: Postgresql 9.0.2 explain analyze very slow (10x), compared to actual query time Date: Fri, 14 Jan 2011 15:53:38 +0200 User-Agent: KMail/1.9.7 References: <201101111753.22602.achill@matrix.gatewaynet.com> <27365.1294850720@sss.pgh.pa.us> <201101131613.23428.achill@matrix.gatewaynet.com> In-Reply-To: <201101131613.23428.achill@matrix.gatewaynet.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201101141553.38236.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.451 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_BRBL_LASTEXT=1.449 X-Spam-Level: X-Archive-Number: 201101/80 X-Sequence-Number: 36520 =D3=F4=E9=F2 Thursday 13 January 2011 16:13:23 =EF/=E7 Achilleas Mantzios = =DD=E3=F1=E1=F8=E5: >=20 > Next step, if i am lucky tonight, i'll set up a new linux box with 9.0.2 = and load=20 > the same small (coming from FBSD_DEV) database. >=20 > So my problem was twofold : a) EXPLAIN ANALYZE performance, b) the partic= ular slow query. >=20 > It seems there is only b) to solve. (see the previous email) >=20 > A lot of thanx (but stay tuned ;) Linux behaves the same way. I setup postgersql-9.0.2 in a fairly new debian= (Debian GNU/Linux 5.0)=20 (2x AMD athlon @2.2GZ, 4GB Mem) (lets call this LINUX_TEST) with the exact same small db as currently in FBSD_TEST test (derived from F= BSD_DEV) and the times i get for this particular query (known from the previous post= s) are bad=20 (and of course much worse than the faster FBSD_TEST, which is normal since = LINUX_TEST is a slower/older machine) The plans are identical for the two 9.0.2 boxes. (FBSD_TEST, LINUX_TEST) In the LINUX_TEST i have left only postgres running to decrease the uncontr= olled consumption of resources and reduce the probability of swapping (i.e. gave all machine to postgresql) The query is (i rewrite it here) SELECT distinct m.id,coalesce(m.givenname,''),coalesce(m.midname,''),m.surn= ame from marinerstates ms,vessels vsl,mariner m where=20 m.id=3Dms.marinerid and ms.vslid=3Dvsl.id and ms.state=3D'Active' and coale= sce(ms.endtime,now())::date >=3D '2006-07-15' and=20 ms.starttime::date <=3D '2007-01-11' and m.marinertype=3D'Mariner' and m.= id not in=20 (SELECT distinct mold.id from marinerstates msold,vessels vslold,mariner= mold where mold.id=3Dmsold.marinerid and msold.vslid=3Dvslold.id and=20 msold.state=3D'Active' and coalesce(msold.endtime,now())::date >=3D '20= 06-07-15' and msold.starttime::date <=3D '2007-01-11' and=20 exists (select 1 from marinerstates msold2 where msold2.marinerid=3Dmso= ld.marinerid and msold2.state=3D'Active' and msold2.id <> msold.id and=20 msold2.starttime=3D '2006-07-15' and=20 ms.starttime::date <=3D '2007-01-11' and m.marinertype=3D'Mariner' and NO= T EXISTS=20 (SELECT distinct mold.id from marinerstates msold,vessels vslold,mariner= mold where mold.id=3Dmsold.marinerid and msold.vslid=3Dvslold.id and=20 msold.state=3D'Active' and coalesce(msold.endtime,now())::date >=3D '200= 6-07-15' and msold.starttime::date <=3D '2007-01-11' and=20 exists (select 1 from marinerstates msold2 where msold2.marinerid=3Dmsol= d.marinerid and msold2.state=3D'Active' and msold2.id <> msold.id and=20 msold2.starttime