From: Tom Lane <tgl@sss.pgh.pa.us>
To: 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: Wed, 13 Jan 2016 10:47:18 -0500
Message-ID: <31259.1452700038@sss.pgh.pa.us> (raw)
In-Reply-To: <CAB=Je-GoKYwmM5TOjYbgJrSYxPUEgJ2hwtFz4U1AWr8x2KKdpQ@mail.gmail.com>
References: <56965183.1080707@joh.to>
<CAB=Je-EDpHs=yfvQ69cZrSytjwG-fi3QN72=xLRQxsd=kU6QOQ@mail.gmail.com>
<56965579.1020909@joh.to>
<CAB=Je-HpQMenktudo7nWWH-YO2034cpx+Djm9Rp3MrLe_mbSgg@mail.gmail.com>
<895FBF7B-D59B-4F58-A8B7-4F78C6A1D527@anarazel.de>
<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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Vladimir Sitnikov <sitnikov.vladimir@gmail.com> writes:
> Note: I state that mixing "kinds" of bind values is a bad application
> design anyway. In other words, application developer should understand
> if a query is DWH-like (requires replans) or OLTP-like (does not
> require replans). Agreed?
No, not agreed. As was already pointed out upthread, such information
is not available in many use-cases for the plancache.
The real problem here IMO is inaccurate plan cost estimates, and that's
not something that there is any easy fix for.
However ... one specific aspect of that is that to some extent, the cost
estimate made for the generic plan is incommensurate with the estimates
for the custom plans because the latter are made with more information.
I don't remember the details of your specific case anymore, but we've
seen cases where the generic plan is falsely estimated to be cheaper
than custom plans because of this.
I wonder whether it would be useful to reject a generic plan anytime its
estimate is less than the average (or minimum?) estimate for the custom
plans. If it is less, then either (1) the generic plan is falsely
optimistic, or (2) the specific parameter values provided for the custom
plans were all ones for which the planner could see that the generic plan
was non-optimal. If (2) holds for the first few custom plans then it's
not unreasonable to suppose that it will keep on holding, and we had
better not use the generic plan.
Basically, the case we're *expecting* to see is that a custom plan is the
same or better cost as the generic plan --- same cost if it's really the
same plan, better cost if knowing the parameter values allows some
optimization to be performed (LIKE-pattern-to-index conversion, partition
scan suppression via constraint exclusion, etc). If we get a higher cost
estimate for the custom plan then something is fishy and we shouldn't
believe it.
Maybe I'm missing some case where that situation would arise naturally.
Or maybe such a rule wouldn't actually help in very many real-world
cases. But it seems worth looking into.
regards, tom lane
--
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: 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: <31259.1452700038@sss.pgh.pa.us>
References: <56965183.1080707@joh.to> <CAB=Je-EDpHs=yfvQ69cZrSytjwG-fi3QN72=xLRQxsd=kU6QOQ@mail.gmail.com> <56965579.1020909@joh.to> <CAB=Je-HpQMenktudo7nWWH-YO2034cpx+Djm9Rp3MrLe_mbSgg@mail.gmail.com> <895FBF7B-D59B-4F58-A8B7-4F78C6A1D527@anarazel.de> <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>
* 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