Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 9D68E1337B6E for ; Tue, 22 Mar 2011 19:57:14 -0300 (ADT) 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 87688-02 for ; Tue, 22 Mar 2011 22:57:07 +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 D2CDC13364DE for ; Tue, 22 Mar 2011 19:57:06 -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 p2MMuxBM009219; Tue, 22 Mar 2011 18:57:00 -0400 (EDT) To: "Mahadevan, Mridula" cc: "pgsql-performance@postgresql.org" Subject: Re: Analyze on temp table taking very long In-reply-to: <300035A46398FC4D8251A684DE0416737D3B81F3@mvmexp01.tpt.imtn.com> References: <300035A46398FC4D8251A684DE0416737D3B81F3@mvmexp01.tpt.imtn.com> Comments: In-reply-to "Mahadevan, Mridula" message dated "Tue, 22 Mar 2011 09:13:30 -0700" Date: Tue, 22 Mar 2011 18:56:59 -0400 Message-ID: <9218.1300834619@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: 201103/248 X-Sequence-Number: 42927 "Mahadevan, Mridula" writes: > This has been running fine for a while on multiple setups, large and small volumes. The setups all have the same hardware configuration. > On one particular setup with about 200k records and this analyze runs for 45min and then times out(statement timeout is set to 45 min). typically this takes a few seconds at best. But when I move the analyze outside the loop everything runs fine. Is it actually *running*, as in doing something, or is it just blocked? I can't immediately think of any reason for some other process to have a lock on a temp table that belongs to your process; but it seems unlikely that ANALYZE would randomly take much longer than expected unless something was preventing it from making progress. Look into pg_locks and/or watch the backend with strace next time this happens. regards, tom lane