Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TR7dg-0003d4-6o for pgsql-bugs@postgresql.org; Wed, 24 Oct 2012 20:33:20 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TR7dN-0005iw-B0 for pgsql-bugs@postgresql.org; Wed, 24 Oct 2012 20:33:19 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id q9OKX0B2009034; Wed, 24 Oct 2012 16:33:00 -0400 (EDT) From: Tom Lane To: Merlin Moncure cc: pgsql-bugs Subject: Re: Introducing floating point cast into filter drastically changes row estimate In-reply-to: References: <6962.1351106799@sss.pgh.pa.us> Comments: In-reply-to Merlin Moncure message dated "Wed, 24 Oct 2012 14:47:48 -0500" Date: Wed, 24 Oct 2012 16:33:00 -0400 Message-ID: <9033.1351110780@sss.pgh.pa.us> X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201210/220 X-Sequence-Number: 34520 Merlin Moncure writes: > Yeah -- I have a case where a large number of joins are happening that > have a lot of filtering based on expressions and things like that. Might be worth your while to install some indexes on those expressions, if only to trigger collection of stats about them. > I've been thinking about this all morning and I think there's a > fundamental problem here: the planner is using low confidence > estimates in order to pick plans that really only be used when the > plan is relatively precise. In particular, I think the broad > assumption that rows pruned via default selectivity should be capped, > say to the lesser of 1000 or the greatest known value if otherwise > constrained. I think that any such thing would probably just move the pain around. As a recent example, just the other day somebody was bleating about a poor rowcount estimate for a pattern match expression, which I suspect was due to the arbitrary limit in patternsel() on how small a selectivity it will believe. I'd rather look for excuses to remove those sorts of things than add more. regards, tom lane