X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CB3ACD1B52C for ; Tue, 12 Aug 2003 00:53:23 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 66985-05 for ; Mon, 11 Aug 2003 21:51:55 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id CCD69D1B524 for ; Mon, 11 Aug 2003 21:53:12 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3504025; Mon, 11 Aug 2003 17:53:24 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Tom Lane Subject: Re: Odd problem with performance in duplicate database Date: Mon, 11 Aug 2003 17:51:39 -0700 User-Agent: KMail/1.4.3 Cc: pgsql-performance@postgreSQL.org References: <200308111716.22288.josh@agliodbs.com> <27573.1060648162@sss.pgh.pa.us> In-Reply-To: <27573.1060648162@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200308111751.39998.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/190 X-Sequence-Number: 3007 Tom, > Partly. The numbers suggest that in ANALYZE's default sample of 3000 > rows, it's only finding about a dozen non-null tgroup_ids (yielding the > 0.996 null_frac value); and that in one case all dozen are different and > in the other case there are two duplicates. It would help if you > boosted the stats target for this column by a factor of 10. (You can > do that in 7.2, btw --- IIRC the only problem is that a pg_dump won't > show that you did so.) Hmmm. No dice. I raised the selectivity to 1000, which increased n_disti= nct=20 to 108, which is pretty close to accurate. However, the planner still=20 insists on using a seq scan on case_clients unless I drop random_page_cost = to=20 1.5 (which is up from 1.2 but still somewhat unreasonable). > But the other part of the problem is that in 7.2, the join selectivity > estimator is way off when you are joining a unique column (like the pkey > on the other side) to a column with a very large fraction of nulls. > We only discovered this recently; it's fixed as of 7.3.3: OK, I'll talk to the client about upgrading. --=20 -Josh Berkus ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco