From: Bruce Momjian <bruce@momjian.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Albe Laurenz <laurenz.albe@wien.gv.at>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Cc: Dave Cramer <pg@fastcrypt.com>
Subject: Re: Fwd: [JDBC] Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
Date: Mon, 18 Jan 2016 16:02:57 -0500
Message-ID: <20160118210257.GO31313@momjian.us> (raw)
In-Reply-To: <6647.1453144451@sss.pgh.pa.us>
References: <CAB=Je-Gqj_vAxu7uYd0oS-DYvnJHpCPVeARebLGmUD+dNpW6Ew@mail.gmail.com>
<5696604E.2030903@joh.to>
<CAB=Je-GazsaWgxQyRW_E=w7938vZH0Xm2gd7jhxE8y+2ixi_mg@mail.gmail.com>
<569660D9.7010107@joh.to>
<CAB=Je-FrTD=M3hMY2qcE8o-tSUpqnkHEwLpY2p-PkJSZS7+yxQ@mail.gmail.com>
<20160113144318.7jcsd5wldolczjb5@alap3.anarazel.de>
<CAB=Je-GoKYwmM5TOjYbgJrSYxPUEgJ2hwtFz4U1AWr8x2KKdpQ@mail.gmail.com>
<31259.1452700038@sss.pgh.pa.us>
<20160118185522.GN31313@momjian.us>
<6647.1453144451@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
On Mon, Jan 18, 2016 at 02:14:11PM -0500, Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> 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 <bruce@momjian.us> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: bruce@momjian.us, tgl@sss.pgh.pa.us, sitnikov.vladimir@gmail.com, andres@anarazel.de, marko@joh.to, pavel.stehule@gmail.com, laurenz.albe@wien.gv.at, pgsql-hackers@postgresql.org, pg@fastcrypt.com
Subject: Re: Fwd: [JDBC] Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102
In-Reply-To: <20160118210257.GO31313@momjian.us>
References: <CAB=Je-Gqj_vAxu7uYd0oS-DYvnJHpCPVeARebLGmUD+dNpW6Ew@mail.gmail.com> <5696604E.2030903@joh.to> <CAB=Je-GazsaWgxQyRW_E=w7938vZH0Xm2gd7jhxE8y+2ixi_mg@mail.gmail.com> <569660D9.7010107@joh.to> <CAB=Je-FrTD=M3hMY2qcE8o-tSUpqnkHEwLpY2p-PkJSZS7+yxQ@mail.gmail.com> <20160113144318.7jcsd5wldolczjb5@alap3.anarazel.de> <CAB=Je-GoKYwmM5TOjYbgJrSYxPUEgJ2hwtFz4U1AWr8x2KKdpQ@mail.gmail.com> <31259.1452700038@sss.pgh.pa.us> <20160118185522.GN31313@momjian.us> <6647.1453144451@sss.pgh.pa.us> <20160118210257.GO31313@momjian.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox