Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A67909FBAB0 for ; Thu, 8 Mar 2007 11:30:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 66535-05 for ; Thu, 8 Mar 2007 11:29:57 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.229]) by postgresql.org (Postfix) with ESMTP id D1AF89FBACF for ; Thu, 8 Mar 2007 11:30:08 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id i28so539019wxd for ; Thu, 08 Mar 2007 07:30:07 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=uVQUqswpC7qFTISFw/iY29Huv+hHIrnvbsTUKeNyeIEAv0iGOMh9znuUs7ACWR1OtsciXhm8835konHRYRtvxKrTxtdRWG5tTVFtMb8O+XWwEyLpLvYgT/tyMZSpTodGA1qYJkTrjVa1Q0XtDIaYj4AH22+OGhxu5VBMmYlMlgs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=gODXO9td5E8BMreQydSP7jt0X2q2qUEENNY+i36IJ0rvy3UiPOxXbJDFmJhc1kwasNplSpHJH+mXgL3Pe91tlG8za6fXXppyYVO7GTOJ4KyzsWhyYT2VMwEjfWCxSsDmaFzcKFnrCzY+CuJcd8SqscUavnZXSFUx0dWKMCQ98jQ= Received: by 10.70.74.6 with SMTP id w6mr900480wxa.1173367807566; Thu, 08 Mar 2007 07:30:07 -0800 (PST) Received: from ?192.168.1.45? ( [71.243.113.55]) by mx.google.com with ESMTP id i12sm1890012wxd.2007.03.08.07.30.05; Thu, 08 Mar 2007 07:30:06 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: <19988.1173285440@sss.pgh.pa.us> References: <9BAE31C9-93A6-48AE-AFED-3BB1947D13F1@gmail.com> <25081.1173146092@sss.pgh.pa.us> <43756010-6EF6-4F91-B84E-E7D29599C3E8@gmail.com> <5644.1173199253@sss.pgh.pa.us> <3FB60C33-F8C7-4E6C-A02C-1D15605C4E96@gmail.com> <19988.1173285440@sss.pgh.pa.us> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <1DD346B1-B8FF-4A0A-950F-A8976B85B78C@gmail.com> Content-Transfer-Encoding: 7bit From: Jeff Cole Subject: Re: Date: Thu, 8 Mar 2007 10:30:03 -0500 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/166 X-Sequence-Number: 23571 Hi Tom, thanks for the great job getting to the core of this problem... I would say I'm not sure I want randomize the rows (not really even sure how to do it without truncating the table and re- adding the records in a random order). I think for the moment I will either a) re-write the query per Ismo's suggestion, or b) wait until more data comes into that table, potentially kicking the query planner into not using the Nested Loop anymore. Anyway, thanks again, I appreciate it... -Jeff On Mar 7, 2007, at 11:37 AM, Tom Lane wrote: > Jeff Cole writes: >> Hi Tom, you are correct, the distribution is uneven... In the 13k >> symptom_reports rows, there are 105 distinct symptom_ids. But the >> first 8k symptom_reports rows only have 10 distinct symptom_ids. >> Could this cause the problem and would there be anything I could do >> to address it? > > Ah-hah, yeah, that explains it. Is it worth your time to deliberately > randomize the order of the rows in symptom_reports? It wasn't clear > whether this query is actually something you need to optimize. You > might have other queries that benefit from the rows being in nonrandom > order, so I'm not entirely sure that this is a good thing to do ... > > regards, tom lane