X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 0892611F7AF3 for ; Tue, 11 Apr 2006 18:30:08 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 0.12 X-Spam-Level: X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id Iw6b3Je0OkpR for ; Tue, 11 Apr 2006 18:28:54 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from crestone.coronasolutions.com (crestone.coronasolutions.com [66.45.104.24]) by postgresql.org (Postfix) with ESMTP id E5D1411F6AB4 for ; Tue, 11 Apr 2006 18:21:54 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by crestone.coronasolutions.com (Postfix) with ESMTP id 8C94D644431; Tue, 11 Apr 2006 15:21:54 -0600 (MDT) Received: from crestone.coronasolutions.com ([127.0.0.1]) by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28173-08; Tue, 11 Apr 2006 15:21:49 -0600 (MDT) Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net [67.165.220.189]) by crestone.coronasolutions.com (Postfix) with ESMTP id 36689644419; Tue, 11 Apr 2006 15:21:49 -0600 (MDT) Message-ID: <443C1DEC.4080307@drivefaster.net> Date: Tue, 11 Apr 2006 15:21:48 -0600 From: Dan Harris User-Agent: Thunderbird 1.5 (Macintosh/20060122) MIME-Version: 1.0 To: Tom Lane Cc: PostgreSQL Performance Subject: Re: Encouraging multi-table join order References: <443AAC26.4070802@drivefaster.net> <1543.1144710756@sss.pgh.pa.us> <443AEF9B.3000909@drivefaster.net> <2406.1144717297@sss.pgh.pa.us> <443C18AA.3000500@drivefaster.net> <10770.1144789733@sss.pgh.pa.us> In-Reply-To: <10770.1144789733@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net X-Archive-Number: 200604/245 X-Sequence-Number: 18329 Tom Lane wrote: > What the stats entry is saying is that the most common entries occur > about 75000 times apiece (0.00166667 * 45e6), which is what's scaring > the planner here ;-). I think those frequencies are artificially high > though. The default statistics sample size is 3000 rows (300 * > statistics target, actually), so those numbers correspond to 5 or 4 > rows in the sample, which is probably just random chance. > > Try increasing the stats targets for this table to 100, then re-ANALYZE > and see what you get. The most_common_freqs entries might drop as much > as a factor of 10. > > regards, tom lane > Tom: I believe this was the problem. I upped the statistics to 100, for a sample size of 30k and now the planner does the correct nested loop/index scan and takes only 30 seconds! This is a HUGE performance increase. I wonder why the estimates were so far off the first time? This table has been ANALYZED regularly ever since creation. Once again, thank you and all of the developers for your hard work on PostgreSQL. This is by far the most pleasant management experience of any database I've worked on. -Dan