Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id BF4AA9FA495 for ; Wed, 26 Sep 2007 12:22:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 01563-03-6 for ; Wed, 26 Sep 2007 12:22:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 7A0F19FA5B0 for ; Wed, 26 Sep 2007 12:22:22 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l8QFMHKV021583; Wed, 26 Sep 2007 11:22:17 -0400 (EDT) To: Csaba Nagy cc: Simon Riggs , postgres performance list Subject: Re: Searching for the cause of a bad plan In-reply-to: <1190818357.5430.29.camel@PCD12478> References: <1190369024.4661.173.camel@PCD12478> <6175.1190390913@sss.pgh.pa.us> <1190396352.4202.109.camel@ebony.site> <13644.1190397220@sss.pgh.pa.us> <1190399879.4202.127.camel@ebony.site> <27857.1190417434@sss.pgh.pa.us> <1190640429.4181.165.camel@ebony.site> <1190818357.5430.29.camel@PCD12478> Comments: In-reply-to Csaba Nagy message dated "Wed, 26 Sep 2007 16:52:37 +0200" Date: Wed, 26 Sep 2007 11:22:17 -0400 Message-ID: <21582.1190820137@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/448 X-Sequence-Number: 26993 Csaba Nagy writes: > db=# analyze verbose temp_table_a; > INFO: analyzing "public.temp_table_a" > INFO: "temp_table_a": scanned 3000 of 655299 pages, containing 1887000 live rows and 0 dead rows; 3000 rows in sample, 412183071 estimated total rows Hmm. So the bottom line here is probably that that's not a big enough sample to derive a realistic n_distinct value. Or maybe it is ... how many values of "a" are there really, and what's the true distribution of counts? Do the plan estimates get closer to reality if you set a higher statistics target? regards, tom lane