Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2668E633D58 for ; Mon, 30 Mar 2009 17:39:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 71014-09 for ; Mon, 30 Mar 2009 17:39:54 -0300 (ADT) Received: from mx3.hub.org (mx3.hub.org [206.223.169.73]) by mail.postgresql.org (Postfix) with ESMTP id 7FD07633CB8 for ; Mon, 30 Mar 2009 17:39:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lists.commandprompt.com (host-159.commandprompt.net [207.173.203.159]) by mx3.hub.org (Postfix) with ESMTP id A751037B4B6 for ; Mon, 30 Mar 2009 17:39:53 -0300 (ADT) Received: from perhan.alvh.no-ip.org (200-126-96-54.bk7-dsl.surnet.cl [200.126.96.54]) (authenticated bits=0) by lists.commandprompt.com (8.13.8/8.13.8) with ESMTP id n2UKkc10029697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 30 Mar 2009 13:46:43 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 42461F7189; Mon, 30 Mar 2009 16:39:39 -0400 (CLT) Date: Mon, 30 Mar 2009 16:39:39 -0400 From: Alvaro Herrera To: dan@sidhe.org Cc: Robert Haas , Scott Marlowe , pgsql-performance@postgresql.org Subject: Re: Trying to track down weird query stalls Message-ID: <20090330203939.GF23023@alvh.no-ip.org> References: <58166.199.172.169.15.1238435452.squirrel@localhost> <603c8f070903301131p8086067ob552d09e8b21c82@mail.gmail.com> <56921.199.172.169.36.1238438533.squirrel@localhost> <57654.199.172.169.17.1238442145.squirrel@localhost> <56164.199.172.169.17.1238443348.squirrel@localhost> <603c8f070903301313u1a9606a3m27da187b5e376785@mail.gmail.com> <56504.199.172.169.35.1238445194.squirrel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56504.199.172.169.35.1238445194.squirrel@localhost> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (lists.commandprompt.com [207.173.203.159]); Mon, 30 Mar 2009 13:46:44 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/428 X-Sequence-Number: 33350 dan@sidhe.org escribió: > where libinstance.libdate <= 1238445044 > and libinstance.enddate > 1238445044 > and libinstance.libinstanceid = libobject.libinstanceid > and libinstance.architecture = ? How are you generating the explain? My bet is that you're just substituting a literal in the architecture condition, but if the driver is smart then maybe it's preparating the query beforehand. You'll get a different plan in that case. Try something like this: prepare foo(smallint) as ... where libinstance.architecture = $1 ... explain analyze execute foo(1); If the plan you get from that is bad (and it often is), you should look at avoiding a query prepare. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support