Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 36128133798E for ; Wed, 12 Jan 2011 07:18:54 -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 23165-09 for ; Wed, 12 Jan 2011 11:18:47 +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 2E7B7133616B for ; Wed, 12 Jan 2011 07:18:45 -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 p0CBIjbT073103 for ; Wed, 12 Jan 2011 13:18:45 +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 p0CBIimw073102 for pgsql-admin@postgresql.org; Wed, 12 Jan 2011 13:18:44 +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: Wed, 12 Jan 2011 13:18:43 +0200 User-Agent: KMail/1.9.7 References: <201101111753.22602.achill@matrix.gatewaynet.com> <18991.1294762751@sss.pgh.pa.us> In-Reply-To: <18991.1294762751@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201101121318.44007.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/57 X-Sequence-Number: 36497 =D3=F4=E9=F2 Tuesday 11 January 2011 18:19:11 =EF/=E7 Tom Lane =DD=E3=F1=E1= =F8=E5: > Achilleas Mantzios writes: > > I have noticed that in 9.0.2 EXPLAIN ANALYZE takes considerably longer = time to return than the actual query. I never noticed this in 8.3. >=20 > Same hardware? What it sounds like is you're running 9.0 on a machine > with slow gettimeofday(). >=20 It is on a different hardware. I have three setups here, i have written a s= mall program to assess gettimeofday. My setups are as follows 1) Prod machine (thereafter called LINUX_PROD) : System: Linux Suse 2.6.16.46-0.12-smp, 16 x Intel Xeon(R) X7350 @ 2.93GHz, = 64GB memory DB: PostgreSQL 8.3.13, shared_buffers=3D16GB, work_mem=3D512MB, db size=3D9= 4GB 2) Dev machine (therafter called FBSD_DEV) : System : FreeBSD 6.3, Intel(R) Core(TM)2 Duo CPU @ 2.80GHz, 2GB memory DB: PostgreSQL 8.3.13, shared_buffers=3D512MB, work_mem=3D1MB, db size=3D76= GB 3) Test machine (thereafter called FBSD_TEST) : System: FreeBSD 8.1, 4 x AMD Phenom(tm) 965 @ 3.4 GHz, 8GB memory DB: PostgreSQL 9.0.2, shared_buffers=3D5GB, work_mem=3D512MB, db size=3D7GB The FBSD_TEST system, in the majority of cases seems to outperform LINUX_P= ROD (rough impression watching execution times of my app, random benchmarks, no= thing too detailed, but it is still a very fast system, and i have been testing for over 2 months with this new system, testing 9.0= =2E2 performance, etc..) However i found two issues with FBSD_TEST: The EXPLAIN ANALYZE performance,= and one specific query which runs considerably slower in FBSD_TEST than both LINUX_PROD and FBSD_D= EV. Regarding gettimeofday (2), i wrote this program : #include #include #include int main(int argc,char** argv) { struct timeval *tp=3Dcalloc(1,sizeof(struct timeval)); int runna; for (runna=3D0;runna<1000000;runna++) { int rc=3Dgettimeofday(tp,NULL); long micros =3D tp->tv_sec * 1000000 + tp->tv_usec; printf("cur_time=3D%u micro secs\n",micros); } } =46or some reason, LINUX_PROD runs this program much much faster than the t= wo FBDs (FBSD_DEV, FBSD_PROD) I get these values for=20 % time ./gettimeofday_test > /dev/null LINUX_PROD real=3D0m0.373s, user=3D0m0.364s, sys=3D0m0.004s =46BSD_DEV real=3D4.29s, user=3D0.526s, sys=3D3.764s =46BSD_TEST real=3D1.66s, user=3D0.260s, sys=3D1.407s So at least regarding gettimeofday, and setting linux aside, the slower fbs= d (FBSD_DEV) seems considerably slower than the faster fbsd (FBSD_TEST). However for the query: SELECT distinct m.id,coalesce(m.givenname,''),coalesce(m.midname,''),m.surn= ame from marinerstates ms,vessels vsl,mariner m=20 where m.id=3Dms.marinerid and ms.vslid=3Dvsl.id and ms.state=3D'Active' and= coalesce(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 mo= ld where mold.id=3Dmsold.marinerid and msold.vslid=3Dvslold.id and=20 msold.state=3D'Active' and coalesce(msold.endtime,now())::date >=3D '2006-0= 7-15' and msold.starttime::date <=3D '2007-01-11' and exists=20 (select 1 from marinerstates msold2 where msold2.marinerid=3Dmsold.marineri= d and msold2.state=3D'Active' and msold2.id <> msold.id and=20 msold2.starttime regards, tom lane >=20 =2D-=20 Achilleas Mantzios