X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3A5BC9FA5C8 for ; Mon, 5 Jun 2006 17:07:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 73739-05 for ; Mon, 5 Jun 2006 17:07:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 155B89FA30C for ; Mon, 5 Jun 2006 17:07:20 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k55K7J6J022707; Mon, 5 Jun 2006 16:07:19 -0400 (EDT) To: Chris Beecroft cc: pgsql-performance@postgresql.org Subject: Re: Some queries starting to hang In-reply-to: <1149534308.3583.56.camel@bg002441.pro-unlimited.com> References: <1149534308.3583.56.camel@bg002441.pro-unlimited.com> Comments: In-reply-to Chris Beecroft message dated "Mon, 05 Jun 2006 12:05:08 -0700" Date: Mon, 05 Jun 2006 16:07:19 -0400 Message-ID: <22706.1149538039@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/41 X-Sequence-Number: 19398 Chris Beecroft writes: > Our problem is that about a week and a half ago we started to get some > queries that would (seemingly) never return (e.g., normally run in a > couple minutes, but after 2.5 hours, they were still running, the > process pushing the processor up to 99.9% active). > Attached are an example query plan: Query.sql > The query plan from our production sever: QueryPlanBroke.txt > The working query plan from our backup server: QueryPlanWork.txt Note the major difference in estimated row counts. That's the key to your problem... you need to find out why the "broke" case thinks only one row is getting selected. broke: > -> Nested Loop (cost=30150.77..129334.04 rows=1 width=305) work: > -> Hash Join (cost=30904.77..125395.89 rows=1810 width=306) I'm wondering about out-of-date or nonexistent ANALYZE stats, missing custom adjustments of statistics target settings, etc. regards, tom lane