Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aLGx9-0002iB-Jy for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2016 21:03:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aLGx9-0005TM-5h for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Jan 2016 21:03:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aLGx7-0005SE-RG for pgsql-hackers@postgresql.org; Mon, 18 Jan 2016 21:03:05 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aLGx3-0003mk-VO for pgsql-hackers@postgresql.org; Mon, 18 Jan 2016 21:03:04 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1aLGwz-0002fW-9B; Mon, 18 Jan 2016 16:02:57 -0500 Date: Mon, 18 Jan 2016 16:02:57 -0500 From: Bruce Momjian To: Tom Lane Cc: Vladimir Sitnikov , Andres Freund , Marko Tiikkaja , Pavel Stehule , Albe Laurenz , PostgreSQL-development , Dave Cramer Subject: Re: Fwd: [JDBC] Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102 Message-ID: <20160118210257.GO31313@momjian.us> References: <5696604E.2030903@joh.to> <569660D9.7010107@joh.to> <20160113144318.7jcsd5wldolczjb5@alap3.anarazel.de> <31259.1452700038@sss.pgh.pa.us> <20160118185522.GN31313@momjian.us> <6647.1453144451@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6647.1453144451@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Mon, Jan 18, 2016 at 02:14:11PM -0500, Tom Lane wrote: > Bruce Momjian writes: > > I never understood why we don't just keep the selectivity estimates of > > previous plans and just reuse the plan if the selectivity estimates are > > similar. Isn't parameter selectivity the only thing that distinguishes > > on plan with parameter from another? > > > Checking selectivity estimates must be cheaper than replanning. This > > could be done at the second use of the prepared plan, and maybe for all > > plan reuses, rather than waiting for five and then perhaps getting this > > bad behavior. > > You're imagining that a selectivity recheck could be separated out from > the rest of the planner. That's nowhere near feasible, IMO. Even if it I think you would have to do the checks before entering the planner and save them off for use in the planner. > were, what would we do with it? There's no reliable way to determine > whether X% change in one or another selectivity number would change the > selected plan, other than by redoing practically all of the planning work. Well, if it is +/-1%, I think we can assume we can reuse the plan just fine from the second prepared call until we see a major selectivity change. While we have never exposed the count of prepared queries before we choose a generic plan, I can see us exposing this percentage. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Roman grave inscription + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers