Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D82F31337BC3 for ; Wed, 12 Jan 2011 11:08:03 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 58108-08 for ; Wed, 12 Jan 2011 15:07:56 +0000 (UTC) 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 mail.postgresql.org (Postfix) with ESMTP id 719D01337BBB for ; Wed, 12 Jan 2011 11:07:56 -0400 (AST) 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 p0CF7r1l025678; Wed, 12 Jan 2011 10:07:53 -0500 (EST) To: Achilleas Mantzios cc: pgsql-admin@postgresql.org Subject: Re: Postgresql 9.0.2 explain analyze very slow (10x), compared to actual query time In-reply-to: <201101121318.44007.achill@matrix.gatewaynet.com> References: <201101111753.22602.achill@matrix.gatewaynet.com> <18991.1294762751@sss.pgh.pa.us> <201101121318.44007.achill@matrix.gatewaynet.com> Comments: In-reply-to Achilleas Mantzios message dated "Wed, 12 Jan 2011 13:18:43 +0200" Date: Wed, 12 Jan 2011 10:07:53 -0500 Message-ID: <25677.1294844873@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/58 X-Sequence-Number: 36498 Achilleas Mantzios writes: > Regarding gettimeofday (2), i wrote this program : > #include > #include > #include > int main(int argc,char** argv) { > struct timeval *tp=calloc(1,sizeof(struct timeval)); > int runna; > for (runna=0;runna<1000000;runna++) { > int rc=gettimeofday(tp,NULL); > long micros = tp->tv_sec * 1000000 + tp->tv_usec; > printf("cur_time=%u micro secs\n",micros); > } > } Right offhand I'd wonder whether that was more bound by gettimeofday or by printf. Please try it without printf in the loop. > 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=5GB, work_mem=512MB, db size=7GB The shared_buffers setting seems way out of line compared to actual memory on this machine. Maybe it's swapping. > i get the following execution times: (with \timing) (note however that FBSD_DEV has a considerably smaller database, the other two are compareable) > FBSD_DEV : query : 240,419 ms, EXPLAIN ANALYZE query : Total runtime: 538.468 ms > LINUX_PROD : query : 219.568 ms, EXPLAIN ANALYZE query : Total runtime: 216.926 ms > FBSD_TEST : query : 2587,465 ms, EPXLAIN ANALYZE query : Total runtime: 93711.648 ms > The last numbers seem huge. Are they in fact the same query plans in each case? regards, tom lane