Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 38BBA450672 for ; Wed, 11 Jan 2012 20:01:30 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rl86f-0005fC-W3 for pgsql-bugs@postgresql.org; Thu, 12 Jan 2012 00:01:30 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id q0C011Q8029571; Wed, 11 Jan 2012 19:01:01 -0500 (EST) To: Andres Freund cc: pgsql-bugs@postgresql.org, casey.shobe@messagesystems.com Subject: Re: Botched estimation in eqjoinsel_semi for cases without reliable ndistinct In-reply-to: <201201112110.40403.andres@anarazel.de> References: <201201112110.40403.andres@anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 11 Jan 2012 21:10:40 +0100" Date: Wed, 11 Jan 2012 19:01:01 -0500 Message-ID: <29570.1326326461@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/94 X-Sequence-Number: 32161 Andres Freund writes: > Whats your opinion on this? Looks pretty bogus to me. You're essentially assuming that the side of the join without statistics is unique, which is a mighty dubious assumption. (In cases where we *know* it's unique, something like this could be reasonable, but I believe get_variable_numdistinct already accounts for such cases.) The reason for the reversion to pre-8.4 behavior was that with the other behavior, we might sometimes make extremely optimistic estimates (ie, conclude that the join result is very small) on the basis of, really, nothing at all. AFAICS this proposal just reintroduces unwarranted assumptions, and therefore will probably produce as many worse results as better ones. Also, why the asymmetry in null handling? And why did you only touch one of the two code paths in eqjoinsel_semi? They have both got this issue of how to estimate with inadequate stats. regards, tom lane