Re: Avoiding bad prepared-statement plans.

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Bart Samwel <bart(at)samwel(dot)tk>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Jeroen Vermeulen <jtv(at)xs4all(dot)nl>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Avoiding bad prepared-statement plans.
Date: 2010-02-11 12:25:28
Message-ID: 162867791002110425r2a0b41cu5e4ee979a7f1f716@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/2/11 Bart Samwel <bart(at)samwel(dot)tk>:
> Hi Robert,
>
> On Tue, Feb 9, 2010 at 17:43, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>
>> On Tue, Feb 9, 2010 at 7:08 AM, Jeroen Vermeulen <jtv(at)xs4all(dot)nl> wrote:
>> > = Projected-cost threshold =
>> >
>> > If a prepared statement takes parameters, and the generic plan has a
>> > high
>> > projected cost, re-plan each EXECUTE individually with all its parameter
>> > values bound.  It may or may not help, but unless the planner is vastly
>> > over-pessimistic, re-planning isn't going to dominate execution time for
>> > these cases anyway.
>>
>> How high is high?
>
> Perhaps this could be based on a (configurable?) ratio of observed planning
> time and projected execution time. I mean, if planning it the first time
> took 30 ms and projected execution time is 1 ms, then by all means NEVER
> re-plan. But if planning the first time took 1 ms and resulted in a
> projected execution time of 50 ms, then it's relatively cheap to re-plan
> every time (cost increase per execution is 1/50 = 2%), and the potential
> gains are much greater (taking a chunk out of 50 ms adds up quickly).

It could be a good idea. I don't belive to sophisticate methods. There
can be a very simply solution. The could be a "limit" for price. More
expensive queries can be replaned every time when the price will be
over limit.

Regards

Pavel Stehule
>
> Cheers,
> Bart
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-02-11 12:27:28 Re: Re: [COMMITTERS] pgsql: Make standby server continuously retry restoring the next WAL
Previous Message Heikki Linnakangas 2010-02-11 12:22:16 Re: Re: [COMMITTERS] pgsql: Make standby server continuously retry restoring the next WAL