pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chapman Flack <chap@anastigmatix.net>
To: Marko Tiikkaja <marko@joh.to>
To: Pavel Stehule <pavel.stehule@gmail.com>
To: Vladimir Sitnikov <sitnikov.vladimir@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 09:25:09 -0500
Message-ID: <56965E45.6020401@anastigmatix.net> (raw)
In-Reply-To: <569650E5.1020102@joh.to>
References: <n708gj$348$1@ger.gmane.org>
	<CADK3HH+GZa+USn1iD_DCoVPF0k8WiM9R6Ms6moV_EbC2fwusLg@mail.gmail.com>
	<n70f5b$j8k$1@ger.gmane.org>
	<CADK3HHJFGjNXJns4exfw_NMGvKAR-1g2RTwvHcbVKK65kuHgEg@mail.gmail.com>
	<n72fhe$cf8$1@ger.gmane.org>
	<CADK3HHLn46DhtfgsnLnpvFhZHHnj3x3vohmF9V53RRtbFacK4w@mail.gmail.com>
	<5694EE5B.1030203@joh.to>
	<CADK3HHKd0n-42ZnVA=X-m4Dxg5Tvrgb+4xGX7T1iuBnXHPNxQw@mail.gmail.com>
	<CAB=Je-G_oBsdrjWuPNsb0jcQ9X1A9jygCnKZW2izejoYG5YoeA@mail.gmail.com>
	<A737B7A37273E048B164557ADEF4A58B537B3510@ntex2010i.host.magwien.gv.at>
	<CAB=Je-G-LrJwDX4HjWdtgh0HtW1w4By+DoQBEvELE7wiYBtW5g@mail.gmail.com>
	<CAFj8pRB5+R0HHaBUPHA7aiLYzitoRJYYC7NFFHWKM=JzoT0pyw@mail.gmail.com>
	<CAB=Je-FzFg-gKq8RUkEiXG=XDcXwoZa+Rn8o7XzwNjjJ3_rNJA@mail.gmail.com>
	<CAFj8pRC3PUgJC85YS1b4iskWT=VB4-wvU=PBF0TJRyLBWgPmGQ@mail.gmail.com>
	<CAB=Je-HG1=VBixViLtL4UZgqz15Ou5p0nffq19soP=sVK5ghLg@mail.gmail.com>
	<CAFj8pRDb9noda3rhcZ_sniH2g=_qRminN6pt=NHDBUmDY6m4OQ@mail.gmail.com>
	<569650E5.1020102@joh.to>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Maybe more work, but:

Could a custom plan be cached /along with the values of
the parameters for which it was planned/?  Then it's kind of
a no-brainer to say "if the parameters are the same this time,
I'm probably looking at the best plan already."  Pretty simpleminded,
but at least it would catch the testcase where the plan flips to
a bad one even when literally the very same parameters are used.

Generalizing a little, how about caching a plan along with a
boolean expression tree over the parameters, evaluating to true
if the new parameters are "close enough" to the planned ones so
that the plan is probably still better than generic?

Version zero could just create the expression p1 = oldp1
AND p2 = oldp2 AND p3 = oldp3, and be simply the same as the
first suggestion. But then, how to generate more interesting
and useful validity-expressions for different plan types and
statistics could be a future-work area with some meat to it,
promising successive improvements. Maybe plugins could
supplement it for particular characterized workloads....

-Chap


On 01/13/2016 08:28 AM, Marko Tiikkaja wrote:
> On 13/01/16 14:12, Pavel Stehule wrote:
>> so the strategy - if cost of generic plan is less than some MAGIC
>> CONSTANT
>> (can be specified by GUC), then use generic plan. Elsewhere use a custom
>> plan everytime.
>>
>> It allow to controll the plan reusing. When MAGIC CONSTANT = 0 .. use
>> custom plan everytime, When MAGIC CONSTANT = M, then use generic plan
>> always.
> 
> I don't think that would solve even the original problem without
> effectively disabling generic plans, despite the problem being
> relatively simple.  The generic plan appears to be really cheap, because
> the planner doesn't have the concept of a "worst case".
> 
> 
> .m
> 



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (72+ messages)  latest in thread

Message-ID: <56965E45.6020401@anastigmatix.net>
Permalink:  ../56965E45.6020401@anastigmatix.net/
Also on:    postgresql.org/message-id/56965E45.6020401@anastigmatix.net

 · 

reply

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: chap@anastigmatix.net, marko@joh.to, pavel.stehule@gmail.com, sitnikov.vladimir@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: <56965E45.6020401@anastigmatix.net>
  References: <n708gj$348$1@ger.gmane.org> <n70f5b$j8k$1@ger.gmane.org> <CADK3HHJFGjNXJns4exfw_NMGvKAR-1g2RTwvHcbVKK65kuHgEg@mail.gmail.com> <n72fhe$cf8$1@ger.gmane.org> <CADK3HHLn46DhtfgsnLnpvFhZHHnj3x3vohmF9V53RRtbFacK4w@mail.gmail.com> <5694EE5B.1030203@joh.to> <CADK3HHKd0n-42ZnVA=X-m4Dxg5Tvrgb+4xGX7T1iuBnXHPNxQw@mail.gmail.com> <CAB=Je-G_oBsdrjWuPNsb0jcQ9X1A9jygCnKZW2izejoYG5YoeA@mail.gmail.com> <A737B7A37273E048B164557ADEF4A58B537B3510@ntex2010i.host.magwien.gv.at> <CAB=Je-G-LrJwDX4HjWdtgh0HtW1w4By+DoQBEvELE7wiYBtW5g@mail.gmail.com> <CAFj8pRB5+R0HHaBUPHA7aiLYzitoRJYYC7NFFHWKM=JzoT0pyw@mail.gmail.com> <CAB=Je-FzFg-gKq8RUkEiXG=XDcXwoZa+Rn8o7XzwNjjJ3_rNJA@mail.gmail.com> <CAFj8pRC3PUgJC85YS1b4iskWT=VB4-wvU=PBF0TJRyLBWgPmGQ@mail.gmail.com> <CAB=Je-HG1=VBixViLtL4UZgqz15Ou5p0nffq19soP=sVK5ghLg@mail.gmail.com> <CAFj8pRDb9noda3rhcZ_sniH2g=_qRminN6pt=NHDBUmDY6m4OQ@mail.gmail.com> <569650E5.1020102@joh.to> <56965E45.6020401@anastigmatix.net>

* 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